Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/minify/lib/Minify/Cache/Memcache.php
Go to the documentation of this file.
00001 <?php
00020 class Minify_Cache_Memcache {
00021     
00033     public function __construct($memcache, $expire = 0)
00034     {
00035         $this->_mc = $memcache;
00036         $this->_exp = $expire;
00037     }
00038     
00048     public function store($id, $data)
00049     {
00050         return $this->_mc->set($id, "{$_SERVER['REQUEST_TIME']}|{$data}", 0, $this->_exp);
00051     }
00052     
00053     
00061     public function getSize($id)
00062     {
00063         return $this->_fetch($id)
00064             ? strlen($this->_data)
00065             : false;
00066     }
00067     
00077     public function isValid($id, $srcMtime)
00078     {
00079         return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
00080     }
00081     
00087     public function display($id)
00088     {
00089         echo $this->_fetch($id)
00090             ? $this->_data
00091             : '';
00092     }
00093     
00101     public function fetch($id)
00102     {
00103         return $this->_fetch($id)
00104             ? $this->_data
00105             : '';
00106     }
00107     
00108     private $_mc = null;
00109     private $_exp = null;
00110     
00111     // cache of most recently fetched id
00112     private $_lm = null;
00113     private $_data = null;
00114     private $_id = null;
00115     
00123     private function _fetch($id)
00124     {
00125         if ($this->_id === $id) {
00126             return true;
00127         }
00128         $ret = $this->_mc->get($id);
00129         if (false === $ret) {
00130             $this->_id = null;
00131             return false;
00132         }
00133         list($this->_lm, $this->_data) = explode('|', $ret, 2);
00134         $this->_id = $id;
00135         return true;
00136     }
00137 }
 All Data Structures Namespaces Files Functions Variables Enumerations