Exemplo n.º 1
0
 public function testSaveOverwritesIfFastIsFull()
 {
     $slowBackend = 'File';
     $fastBackend = $this->getMock('Zend_Cache_Backend_Apc', array('getFillingPercentage'));
     $fastBackend->expects($this->at(0))->method('getFillingPercentage')->will($this->returnValue(0));
     $fastBackend->expects($this->at(1))->method('getFillingPercentage')->will($this->returnValue(90));
     $slowBackendOptions = array('cache_dir' => $this->_cache_dir);
     $cache = new Zend_Cache_Backend_TwoLevels(array('fast_backend' => $fastBackend, 'slow_backend' => $slowBackend, 'slow_backend_options' => $slowBackendOptions, 'stats_update_factor' => 1));
     $id = 'test' . uniqid();
     $cache->save(10, $id);
     //fast usage at 0%
     $cache->save(100, $id);
     //fast usage at 90%
     $this->assertEquals(100, $cache->load($id));
 }
Exemplo n.º 2
0
 public function __construct(array $options = array())
 {
     if (!isset($options['slow_backend_autoload'])) {
         $options['slow_backend_autoload'] = true;
     }
     if (!isset($options['slow_backend'])) {
         $options['slow_backend'] = 'Kwf_Cache_Backend_File';
         $options['slow_backend_custom_naming'] = true;
         if (isset($options['cache_dir'])) {
             $options['slow_backend_options']['cache_dir'] = $options['cache_dir'];
             unset($options['cache_dir']);
         }
     }
     if (!isset($options['fast_backend_autoload'])) {
         $options['fast_backend_autoload'] = true;
     }
     if (!isset($options['fast_backend'])) {
         if (extension_loaded('apc')) {
             $options['fast_backend'] = 'Kwf_Cache_Backend_Apc';
         } else {
             $options['fast_backend'] = 'Kwf_Cache_Backend_Memcached';
         }
         $options['fast_backend_custom_naming'] = true;
     }
     parent::__construct($options);
 }
Exemplo n.º 3
0
 public function save($data, $id, $tags = array(), $specificLifetime = false, $priority = 8)
 {
     parent::save($data, $id, $tags, $specificLifetime, $priority);
     return true;
 }