public static function configure(ezcCacheStack $stack)
 {
     foreach (self::$storages as $storageConf) {
         $stack->pushStorage($storageConf);
     }
     if (self::$metaStorage !== null) {
         $stack->options->metaStorage = self::$metaStorage;
     }
     if (self::$options !== null) {
         $stack->options = self::$options;
     }
 }
Exemple #2
0
 public function testStore()
 {
     $storage1 = $this->getMock('ezcCacheStackableStorage', array('reset', 'purge', 'store'));
     $storage1->expects($this->once())->method('store')->with('id_1', 'id_1_data', array('lang' => 'en'));
     $storage2 = $this->getMock('ezcCacheStackableStorage', array('reset', 'purge', 'store'));
     $storage2->expects($this->once())->method('store')->with('id_1', 'id_1_data', array('lang' => 'en'));
     $stack = new ezcCacheStack('foo');
     $stack->options->metaStorage = $this->getMetaStorageMock();
     $stack->pushStorage(new ezcCacheStackStorageConfiguration('id_1', $storage1, 10, 0.5));
     $stack->pushStorage(new ezcCacheStackStorageConfiguration('id_2', $storage2, 100, 0.7));
     $this->assertNull($stack->store('id_1', 'id_1_data', array('lang' => 'en')));
 }
<?php

require_once 'tutorial_autoload.php';
$stack = new ezcCacheStack('stack');
$stack->pushStorage(new ezcCacheStackStorageConfiguration('file', $fileStorage, 1000000, 0.5));
$stack->pushStorage(new ezcCacheStackStorageConfiguration('apc', $apcStorage, 1000, 0.3));
$stack->options->replacementStrategy = 'ezcCacheStackLfuReplacementStrategy';
// ... somewhere else...
$stack->store('id_1', 'id_1_data');
$stack->store('id_2', 'id_2_data', array('attribute' => 'value'));
$id1data = $stack->restore('id_1');
 public static function configure(ezcCacheStack $stack)
 {
     // ... create your storages here or fetch from manager...
     $stack->pushStorage(new ezcCacheStackStorageConfiguration('file', $fileStorage, 1000000, 0.5));
     $stack->pushStorage(new ezcCacheStackStorageConfiguration('apc', $apcStorage, 1000, 0.3));
 }