SpiderOak / netkes

Networked key escrow server and LDAP sync code for SpiderOak Blue.
15 stars 5 forks source link

Update cache mechanism to account for function arguments #189

Closed sirpengi closed 9 years ago

sirpengi commented 9 years ago

Paged queries to the list_user method were all getting cached with the same key, thus making it so that paging through the user list would always return the same set of users no matter what page we were on.

There was a check in place (if name in FUNCTIONS_TO_CACHE or check_list_users(name, args, kwargs):) but it didn't effectively sidestep the cache as intended. Possibly, changing the or to an and in that check would have fixed this issue, but we then have an issue of never being able to cache beyond the first page.

This PR updates the cache mechanism to account for functions with arguments, with the downside of every api query requiring (an additional) 1-2 cache calls to fetch the method prefix (this method prefix is required in order to invalidate all cached calls for a function - as any function call may have multiple entries due to multiple combinations of arguments). On the one hand, we have more cache access. On the other hand, cache access is fast and api calls are slow, and now we cache a lot more api calls than before.