Ticket Details
Added cache prefix support
PULL REQUEST Ticket (pending)
### The Problem - We were running multiple Lithium apps using the same cache backend (such as Apc or Memcache) and needed a way to keep cache keys separated between apps. - I see \storage\cache\adapter\Apc has a 'prefix' in the default configuration, but I couldn't find it being used anywhere or figure out how to override it. - Obviously, we (or anyone) could subclass Cache to add this functionality. However, I think this is going to be a common problem and it takes some poking around to do it properly (still handling multi-reads and writes was a gotcha I encountered - thank you unit tests). ### My Solution - The Cache::key() method is called without knowing which configuration it is for. Therefore, to add prefix support, I had to resort to looking in the 'default' cache configuration for a 'prefix' key. I had to make the Cache::key() method a bit more verbose in order to handle all use cases. - I updated to Cache docblock and added to \tests\cases\storage\CacheTests.php - Code can be merged from the master.cache-prefix branch on my rmarscher form. - Alternatively you can cherry-pick 03729b29d1c75a3556a39d1f9ea4ce2a26fa1b34
Updates
on 05.27.11
by rmarscher