Finding a PHP Caching Library with Multiple Internal Storage Adapters

I am looking for a PHP caching library with several built-in storage adapters. For example, something that can save the cache in a file or in Memcache.

Here are some of the libraries I found:

+3
source share
4 answers

PEAR also has two libraries; Cache and Cache_Lite . Both of them are not very current, unfortunately, and do not offer memcached servers.

+1
source

Zend_Cache - , . Zend .

+1

Zend_Cache http://framework.zend.com/manual/1.12/en/zend.cache.introduction.html

.

$frontendOptions = array(
    'lifetime' => 7200, // cache lifetime of 2 hours
    'automatic_serialization' => true
);

$backendOptions = array(
    'cache_dir' => './tmp/' // Directory where to put the cache files
);

// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory(
    'Core',
    'File',
    $frontendOptions,
    $backendOptions
);

if (($result = $cache->load('myresult')) === false) {

    // cache miss; connect to the database

    $db = Zend_Db::factory(/* [...] */);

    $result = $db->fetchAll('SELECT * FROM huge_table');

    $cache->save($result, 'myresult');

} else {

    // cache hit! shout so that we know
    echo "This one is from cache!\n\n";

}

print_r($result);
+1
source

My library that can work with APC, Memcache, Memcached, and PHP Shared memory: PHP Memory Cacher

0
source

All Articles