joomla / joomla-framework

[READ-ONLY] This repo is no longer in active development. Please see https://github.com/joomla-framework for the individual Framework packages.
http://framework.joomla.org
GNU General Public License v2.0
188 stars 141 forks source link

Cache needs refactoring #319

Open florianv opened 10 years ago

florianv commented 10 years ago

There are a few issues with the Cache package :

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

piotr-cz commented 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.

ghost commented 10 years ago

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].