Yet another caching system for Drupal with support of memcache, APC, database, file, redis, XCache engines.

More information:

18 Aug 2009 New Drupal "cache" module started.

Started as fork of Cache Router.

Testing

This module is in alpha and needs your help with some testing especially - page_fastcache, session handler.

About

"Cache" module provides bridge between Drupal and alternative cache handler
implementators: e.g. APC, memcache, redis.

It provides implementation of page_fast_cache() function.

Features

  • Additional cache handlers.
  • page_fast_cache() implementation.
  • hook_requirements() implementation. See report status of used cache handlers.
  • Alternative session handler.
  • Set of core patches to improve performance on big Drupal web-sites.
  • In case all alternative cache handlers fail (e.g. no APC, memcache installed) it will use standard database caching. Administrator then may check "Status report" page and see why any of cache handler fails.
  • Cache handlers chaining.

Requirements

By default, "Cache" module doesn't require any additional cache handler implementations. It will use database for cache storage as default Drupal installation does.

Optional requirements

To gain all the features of "Cache" module you might want to install one
or more alternative cache handler engines:

  • PHP APC
  • memcache
  • redis

Installation

1. Enable "Cache" (from "Cache" package) module on
Admininster -> Site building -> Modules page.

2. SETUP WEB-SITE'S settings.php CONFIGURATION FILE

Add the following lines to your settings.php:

<?php
    $conf
['cache_inc'] = './sites/all/modules/cache/cache.inc';
   
$conf['cache_settings'] = array(
     
'engines' => array(
       
'db-engine' => array(
         
'engine' => 'database',
        ),
      ),
     
'schemas' => array(
       
'db-schema' => array(
         
'db-engine',
        )
      ),
     
'bins' => array(
       
'default' => 'db-schema',
      ),
    );
?>

"default" is for the default caching schema. All valid cache bins (tables)
can be added in addition, but you must have a "default" if you skip any bins.

You can add several more cache schemas and use them for bins. Each schema is
array of arrays, each array is contains configuration of engine. If several
engines per schema is specified then cache chaining will be used: for example
if cache entry is not found in 1st engine then we'll try to find it in 2nd,
then in 3rd etc.

To enable alternative session handler you might want to add to web-site's
settings.php:

    $conf['session_inc'] = './sites/all/modules/cache/session.inc';

Then new bins "cache_session" and "cache_session_user" will be created. You may
configure any caching schema for them like for any other table. Aware to use reliable
cache for them (more information: #575742: Login Not Persisten).

To enable alternative path storage handler you might want to add to web-site's
settings.php:

    $conf['path_inc'] = './sites/all/modules/cache/path/path-max.inc';

or

    $conf['path_inc'] = './sites/all/modules/cache/path/path-cache.inc';

This feature also requires core patch "path_inc-variable-support.patch" to be applied.
It can be applied manually or applied through web administration using patchdoq
module if installed: Administer -> Site building -> Patch.

New bins "cache_path_alias" and "cache_path_source" will be created. You may
configure any caching schema for them like for any other table. Aware that
leaving it for default database engine might degrade performance.

For configuration options please look into README.txt file.

Examples of working "Cache" module configuration:

Example #1:

<?php
    $conf
['cache_inc'] = './sites/all/modules/cache/cache.inc';
   
$conf['session_inc'] = './sites/all/modules/cache/session.inc';
   
$conf['cache_settings'] = array(
     
'engines' => array(
       
'db' => array(
         
'engine' => 'database',
         
'server' => array(),
         
'shared' => TRUE,
         
'prefix' => '',
        ),
       
'apc' => array(
         
'engine' => 'apc',
         
'server' => array(),
         
'shared' => TRUE,
         
'prefix' => '',
        ),
       
'memcache' => array(
         
'engine' => 'memcache',
         
'server' => array(
           
'localhost:11211',
           
'localhost:11212',
          ),
         
'shared' => TRUE,
         
'prefix' => '',
        ),
      ),
     
'schemas' => array(
       
'db' => array(
         
// Engines:
         
'db',
        ),
       
'apc' => array(
         
// Engines:
         
'apc',
        ),
       
'memcache' => array(
         
// Engines:
         
'memcache',
        ),
      ),
     
'bins' => array(
       
// Bin name     => Schema name.
       
'default'       => 'db',
       
'cache'         => 'apc',
       
'cache_form'    => 'memcache',
       
'cache_page'    => 'memcache',
       
'cache_filter'  => 'memcache',
      ),
    );
?>

Example #2 (with cache chaining - very rare usage case but may be useful):

<?php
    $conf
['cache_inc'] = './sites/all/modules/cache/cache.inc';
   
$conf['session_inc'] = './sites/all/modules/cache/session.inc';
   
$conf['cache_settings'] = array(
     
'engines' => array(
       
'apc-engine' => array(
         
'engine' => 'apc',
         
'server' => array(),
         
'shared' => TRUE,
         
'prefix' => '',
        ),
       
'memcache-engine' => array(
         
'engine' => 'memcache',
         
'server' => array(
           
'localhost:11211',
           
'localhost:11212',
          ),
         
'shared' => TRUE,
         
'prefix' => '',
        ),
       
'db-engine' => array(
         
'engine' => 'database',
         
'server' => array(),
         
'shared' => TRUE,
         
'prefix' => '',
        ),
      ),
     
'schemas' => array(
       
'apc-memcache-db-schema' => array(
         
// Engines:
          // Primary cache.
         
'apc-engine',
         
// Secondary cache.
         
'memcache-engine',
         
// Another secondary cache, in case both APC and memcache fail.
         
'db-engine',
        ),
       
'apc-schema' => array(
         
// Engines:
         
'apc-engine',
        ),
       
'memcache-schema' => array(
         
// Engines:
         
'memcache-engine',
        ),
      ),
     
'bins' => array(
       
// Bin name     => Schema name.
       
'default'       => 'memcache-schema',
       
'cache'         => 'apc-schema',
       
'cache_form'    => 'apc-memcache-db-schema',
       
'cache_filter'  => 'my-memcache',
      ),
    );
?>

Similar modules

This project is similar in functionality to Cache Router, Advanced cache, Authenticated User Page Caching (Authcache), Memcache API and Integration, fastpath_fscache, Path Cache.

Project Information

Downloads