Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork215
[WIP] Namespaced cache decorator#96
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
andrerom commentedOct 9, 2015
Nice to see this being moved out. |
andrerom commentedOct 9, 2015
Strike that, for bc cache provider will need to implement all anyway, so besides moving names spacing out it can stay as is. |
…limited to the current namespaceSo the decorator just overwrites flushAll. There should not be two methods (flushAll and deleteAll) for the same thing.
Tobion commentedOct 28, 2015
I had another idea which would also make the decorator obsolete. CacheProvider can accept a This would solve another problem at the same time: Currently the allowed cache ids are based on the used adapter. E.g. Memecached does not support whitespaces whereas others caches do. So if people would have to deal with special chars, they can just inject a hash strategy and are set whatever cache adapter they will use. |
andrerom commentedFeb 28, 2016
Time to move this forward? With symfony cache using this now it would be good to be able to avoid this overhead one way or another(for me it is ;)). personally I prefer decorator approach as it then doesn't add any cost when turned off at all. And special rules on cache id's either needs to restrict interface of all, or be normalized in specific adapter imo. Forcing user to match correct name strategy service with adapter is asking for mistakes to happen. |
yellow1912 commentedOct 28, 2016
Any hope for this to be rolled out anytime soon? I need to save to redis in my application but then retrieve from other place. (lua code). The versioning is messing up the expected key. |
yellow1912 commentedOct 28, 2016
@Tobion I think your idea with CacheIdNamingStrategy can work really well. We can then easily support the configuration in DoctrineCacheBundle as well, by specifying the naming service we may want to use. |
Tobion commentedOct 28, 2018
Closing as I don't have intention to finish this one. |
The idea is to implement namespaces using a decorator. This makes much more sense than having namespaces built-into the generic CacheProvider because namspaces only make sense for shared caches. So non-shared caches like ArrayCache should not have namespace logic at all.
Also the need to add namespaces depends on the usage. If a developer uses a global cache like Redis but does not reuse it it many unrelated places (where he cannot ensure cache ids do not collide), there is no point in adding namespaces. This also has the benefit to not add the overhead when not needed. The current overhead comes from reading the namespace version on each fetch. So currently each fetch does two accesses. The version is cached in the CacheProvider to boost the performance, but that can obivously result in race conditions. So this is removed in the decorator.
Decorating a cache with this namespace logic will also make sure that deleting all cache entries using
flushAll()will only remove the cache entries of the given namespace and not everything. This way one application/library can delete all of its cache without interfering with the shared cache of another app/library. This makesClearableCache::deleteAllobsolete. Classes that use a cache should not have to care aboutdeleteAllvsflushAll. They just want to delete the stuff. It's the task of the developer to make use of the namespace decorator when they have a global cache and different places where deletion can occur.Todo
CacheProvider::setNamespaceandCacheProvider::getNamespace. In the next major version we can then remove namespacing from there and thus the cache providers that don't need it like ArrayCache will not by default inherit the namespace overhead.namespaceconfig is usedflushAll(ordeleteAllif we want to settle on this name). This is mainly used in cache clear commands.