Give the gift of Drupal. All merchandise is 50% off through 2016.
NOTE: This project is being superseded by Cache Tags. See that project for future development.
FlexiCache is a cache API wrapper which uses meta data stored in MongoDB to achieve flexible and efficient cache invalidation. It works on top of your existing cache backend, so it's compatible with cacherouter, memcache, etc.
Here's some example usage: you have a social-networking type of site, where the user profile page has a block that displays little avatars of all their contacts. To generate each avatar, maybe an expensive user_load() is necessary, so you enable core block caching on that block. Problem is, any time anyone posts a comment (or one user makes a new contact), cache_clear_all() dumps your block cache too, so all those avatars need to be regenerated constantly for no reason.
Enter FlexiCache: you disable core block caching on that block, and instead use the FlexiCache API. After you generate the block content (cache miss), you can tell FlexiCache the user ID involved with the cache entry:
flexicache_set($cid, $generated_content, 'cache', CACHE_PERMANENT, NULL, array('users' => array($account->uid)));
The uid list is stored in MongoDB, while the actual cache data is stored with the normal pluggable cache backend. Now when the same user makes a new contact, you can selectively clear the cache like so:
flexicache_clear_all(array('users' => $account->uid));
You could even associate this cache entry with ALL the uid's in the contact list, so if one of the avatars involved is updated, you can clear only the entries that contain that avatar.
It's also worth noting that this API is syntactically compatible with the standard Drupal cache API, so the minimal amount of work to switch to using FlexiCache is to simply search and replace instances of cache_* with flexicache_*. To take advantage of the benefits though, you do need to rewrite your code to store meta data when you set the cache, and query on it when you clear.
- Maintenance status: Minimally maintained
- Development status: No further development
- Module categories: Performance and Scalability
- Downloads: 374
- Last modified: November 27, 2014
- Stable releases are covered by the security advisory policy.
Look for the shield icon below.