-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exposing a region's configuration/lock for custom functionality #125
Comments
Changes by jvanasco (jvanasco):
|
Michael Bayer (zzzeek) wrote: are you still identifying all those things by one "key" at the top? if there are still "get" and "set" operations of some kind, why cant the custom backend look up all keys, combine them together, call wahteevr, etc.? the CacheRegion is already oriented around having all the real options dependency-injected. |
jvanasco (jvanasco) wrote: This type of functionality doesn't really work well as a method of a custom region or backend once you scale the amount of regions beyond a certain point. I'm not sure what that point is, but one deployment has 23 regions using 3 backends right now; implementing the raw lock access for custom getcreates into custom regions would just be a nightmare to manage. in typical usage, i've got about 5 unique methods/keys which will share a single key for locking. in the example above, editing any hashfield under this is definitely an advanced case and I don't need a solution for myself - I have a functional workaround. the getcreate logic in dogpile's region and lock is really brilliant, but it seems limited in use because it's not pluggable. |
Michael Bayer (zzzeek) wrote: so the problem is the number of regions and that's why you need to pass the functions in at get() time? clarifying the region is fully pluggable, just not on a per-get basis? or is there a new kind of functionality that cant be done here period with a plugin. I don't understand what the number of regions has to do with anything. |
jvanasco (jvanasco) wrote: tldr: the barrier to simply using a custom backend is the need to use different keys for the Lock template and Cached values.
Mostly this.
In a given region, a getcreate on 5 different backend keys [ Option 1: use 5 identically configured regions, which getcreate on KeyA to make the lock, and use 5 different custom backends to handle the get/set Option 2: use 5 custom regions, which getcreate on Key1-Key5 but share a lock on KeyA, and use 1 standard backend. Because the backends handle plugability of the underlying datastore, it would make more sense to implement this with a custom CacheRegion. |
Michael Bayer (zzzeek) wrote: I dont understand yet why the custom backend can't do all that work, delegating to a real backend to get to the cache itself. your backend gets the key "messages|user_id" and then does waht it needs to get all those things. is it because the individual getcreate() has to call into additional independent getcreate() steps? e.g. one lock operation has to actually involve more dogpile locks? The region implementation can call back to the owning cache region itself if it wanted to, or into another one. put another way, the API you ask for is:
can't possibly work if it was: region = CacheRegion(f_get=f_get) right? That's essentially what this seems to ask |
jvanasco (jvanasco) wrote: It's because multiple backend
On a cache miss, these all need to use the same getcreate lock as
Within Does this make sense? It's not an issue with |
Michael Bayer (zzzeek) wrote: OK, you need the locks to share a key. that can be passed in, "lock_key", very easy. want to do that? |
Michael Bayer (zzzeek) wrote: I mean, basically the answer is no I really don't want to blow up the existing get_or_create as far as its structure, it's complicated enough, to explode that structure even more would mean we really have to have the use case nailed down very clearly becasue somoene else might have another use case we aren't hitting. |
jvanasco (jvanasco) wrote: I'm willing to PR a custom Maybe just leave this ticket open for a while and see if any other use-cases bubble up first? |
Migrated issue, originally created by jvanasco (jvanasco)
with some advanced Redis usage, I need to handle caching certain keys in ways that are incompatible with
dogpile.cache
as-is, and must use thedogpile.core
lock directly. at the same time, I still want to leverage my dogpile region and it's configuration.by "incompatible", i mean various mechanisms that can't be fixed with a custom backend or Proxy. In one example, a key corresponds to a redis hash with messages for a user, and contains at least 3 values (count unread, count read, cached_ids):
getting/updating the message counts requires writing/validating two keys at once (count_read, count_unread). various functions need to happen within a redis pipeline as well.
to handle this sort of operation, I am essentially leveraging the code below - which is based on the getcreate logic
would it make sense to integrate something like this into the CacheRegion itself?
The text was updated successfully, but these errors were encountered: