Open florianv opened 10 years ago
You might be interested in a discussion on Cache package in the past: What to do with the Cache package and here.
BTW PSR-6 (Cache interface) is in the Draft stage, but I fear it may take some time to finalize.
I'm not really thrilled with the implementation, but I will point out that wrapping values inside an object solves the issue of "is null or is not present" - the cache handler ALWAYS returns a cache object - and it will set a boolean flag to note if the value has been found or not.
Returning a cache item allows for the ability to add the cache meta data to the information returned[hits, misses, etc].
Moreover, it does allow for passing cached data around without making many copies..ie objects are always passed by reference.
I personally think that in addition to passing a cache item back, data should be stored as a cache item to begin with.
As for sessions, the Memcached session driver doesn't use a driver at all - it simply defaults to using the built in php functions... Again, not thrilled about this direction, however I think a much simpler solution is to create a CacheEngine class for the Session and allow the session driver to use any Joomla Cache method without requiring special code logic].
There are a few issues with the Cache package :
Memcached
orRedis
are conflicting with the php corresponding classes and you need to alias them when importing which is annoying. Ideally they should be suffixed byDriver
becauseCache
"bugs" with XCache or WinCache (XCacheCache ...)Psr\Cache
which was not accepted AFAIK so the classes need to be moved somewhere else like in the package itself.Item
), it is a big performance overhead.$default
param to theget
function to know if the cache entry value is null or if it is null because not present in the cache.ttl
parameter https://github.com/joomla/joomla-framework/blob/staging/src/Joomla/Cache/Cache.php#L42 but this is used in some drivers and not in some others. Used in Apc https://github.com/joomla/joomla-framework/blob/staging/src/Joomla/Cache/Apc.php#L129 but not used here : https://github.com/joomla/joomla-framework/blob/staging/src/Joomla/Cache/XCache.php#L97\Memcached
driver in the Memcached class or a\Redis
driver in the Redis class for example to share the same instance between Cache and Session.Why not using Doctrine which has already more drivers and fixed most of these issues ? https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache