Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (50 sloc) 1.52 KB


Zend Cache backend which stores objects inside the script's internal memory.

  • This cache backend store objects inside a Zend_Registry namespace
  • The cache objects are stored only across the script's execution
  • Memory cache can be useful in cases that your scripts calls the same function multiple times

The project requires:

  • PHP >= 5.2.1
  • Zend Framework 1.11+

Quick Example:

$frontendOptions = array(
    'automatic_serialization' => true,
    'caching' => true

$backendOptions = array(

// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory('Core',
        new Application_Cache_Backend_Memory,

// initially load the user (from database, memcache..)
$user = fetchUser(10);

// we already loaded this user, so we won't hit the memcache / database again
$user = fetchUser(10);

function fetchUser($userId)
    global $cache;

    $tag = 'user_' . $userId;

    // if we already loaded the user, get his object from the memory
    if (($user = $cache->load($tag)) !== false) {
        $user->from = 'this object came from the memory';
        return $user;   

    // get the user data (very expensive!!)
    $user = new stdClass();
    $user->userId = $userId;
    $user->name = 'John Doe';

    $cache->save($user, $tag);

    return $user;

Build Status

Jump to Line
Something went wrong with that request. Please try again.