ReferencePool.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2005-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: ReferencePool.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00020     final class ReferencePool extends SelectivePeer
00021     {
00022         private $peer = null;
00023         private $pool = array();
00024         
00025         public function __construct(CachePeer $peer)
00026         {
00027             $this->peer = $peer;
00028         }
00029         
00033         public function mark($className)
00034         {
00035             $this->peer->mark($className);
00036             
00037             return $this;
00038         }
00039         
00040         public function get($key)
00041         {
00042             if (isset($this->pool[$key]) && $this->pool[$key])
00043                 return $this->pool[$key];
00044             
00045             return $this->pool[$key] = $this->peer->get($key);
00046         }
00047         
00048         public function delete($key)
00049         {
00050             unset($this->pool[$key]);
00051             
00052             return $this->peer->delete($key);
00053         }
00054         
00058         public function clean()
00059         {
00060             $this->pool = array();
00061             
00062             return $this->peer->clean();
00063         }
00064         
00065         public function isAlive()
00066         {
00067             return $this->peer->isAlive();
00068         }
00069 
00070         protected function store(
00071             $action, $key, &$value, $expires = Cache::EXPIRES_MEDIUM
00072         )
00073         {
00074             $this->pool[$key] = $value;
00075             
00076             return $this->peer->$action($key, $value, $expires);
00077         }
00078     }
00079 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4