Quantcast
Viewing all articles
Browse latest Browse all 426

Consistent Cache

If you're using a cache backend other than the built-in DB, then the cache operations runs outside the database transactions, and this can cause inconsistent cache where cache is being populated with old data.
AutoSlave comes with a cache wrapper that ensures cache is not updated until transactions are committed, thereby preventing old data being populated into cache.

<?php
$conf
['cache_backends'] = array(
 
'sites/all/modules/memcache/memcache.inc',
 
'sites/all/modules/autoslave/autoslave.cache.inc',
);

$conf['cache_default_class'] = 'AutoslaveCache';
$conf['autoslave_cache_default_class'] = 'MemCacheDrupal';
?>

However, if you're using the isolation level REPEATABLE-READ, then the AutoSlave cache wrapper is not enough due to the consistent snapshot feature of InnoDB. In this case, it is also recommended to use the Cache Consistent.

<?php
$conf
['cache_backends'] = array(
 
'sites/all/modules/memcache/memcache.inc',
 
'sites/all/modules/autoslave/autoslave.cache.inc',
 
'sites/all/modules/cache_consistent/cache_consistent.inc',
);

$conf['cache_default_class'] = 'AutoslaveCache';
$conf['autoslave_cache_default_class'] = 'ConsistentCache';
$conf['consistent_cache_default_class'] = 'MemCacheDrupal';
?>

The Consistent Cache writes the cache to both memcache and database, providing a MVCC safe fallback for the cache.


Viewing all articles
Browse latest Browse all 426

Trending Articles