[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/cache/src/ -> lmbCacheCompositePersister.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/cache/src/lmbCachePersister.interface.php');
  10  
  11  /**

  12   * class lmbCacheCompositePersister.

  13   *

  14   * @package cache

  15   * @version $Id: lmbCacheCompositePersister.class.php 5945 2007-06-06 08:31:43Z pachanga $

  16   */
  17  class lmbCacheCompositePersister implements lmbCachePersister
  18  {
  19    protected $persisters = array();
  20  
  21    function registerPersister($persister)
  22    {
  23      $this->persisters[] = $persister;
  24    }
  25  
  26    function getId()
  27    {
  28      return null;
  29    }
  30  
  31    function put($key, $value, $group = 'default')
  32    {
  33      foreach(array_keys($this->persisters) as $index)
  34        $this->persisters[$index]->put($key, $value, $group);
  35    }
  36  
  37    function get($key, $group = 'default')
  38    {
  39      foreach(array_keys($this->persisters) as $index)
  40      {
  41        if(($value = $this->persisters[$index]->get($key, $group)) !== LIMB_CACHE_NULL_RESULT)
  42        {
  43          $this->_putValueToPersisters($index, $value, $key, $group);
  44          return $value;
  45        }
  46      }
  47      return LIMB_CACHE_NULL_RESULT;
  48    }
  49  
  50    function flushValue($key, $group = 'default')
  51    {
  52      foreach(array_keys($this->persisters) as $index)
  53        $this->persisters[$index]->flushValue($key, $group);
  54    }
  55  
  56    function flushGroup($group)
  57    {
  58      foreach(array_keys($this->persisters) as $index)
  59        $this->persisters[$index]->flushGroup($group);
  60    }
  61  
  62    function flushAll()
  63    {
  64      foreach(array_keys($this->persisters) as $index)
  65        $this->persisters[$index]->flushAll();
  66    }
  67  
  68    protected function _putValueToPersisters($index, &$value, $key, $group)
  69    {
  70      for($i=0; $i < $index; $i++)
  71        $this->persisters[$i]->put($key, $value, $group);
  72    }
  73  }
  74  ?>


Generated: Thu Aug 28 04:51:15 2008 Cross-referenced by PHPXref 0.7