RuntimeMemory.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: RuntimeMemory.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00020     final class RuntimeMemory extends CachePeer
00021     {
00022         private $cache = array();
00023         
00027         public static function create()
00028         {
00029             return new self;
00030         }
00031         
00032         public function isAlive()
00033         {
00034             return true;
00035         }
00036         
00037         public function get($key)
00038         {
00039             if (isset($this->cache[$key]))
00040                 return $this->cache[$key];
00041             
00042             return null;
00043         }
00044         
00045         public function delete($key)
00046         {
00047             if (isset($this->cache[$key])) {
00048                 unset($this->cache[$key]);
00049                 return true;
00050             }
00051             
00052             return false;
00053         }
00054         
00058         public function clean()
00059         {
00060             $this->cache = array();
00061             
00062             return parent::clean();
00063         }
00064 
00065         protected function store($action, $key, &$value, $expires = 0)
00066         {
00067             if ($action == 'add' && isset($this->cache[$key]))
00068                 return true;
00069             elseif ($action == 'replace' && !isset($this->cache[$key]))
00070                 return false;
00071             
00072             $this->cache[$key] = $value;
00073             return true;
00074         }
00075     }
00076 ?>

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