
Public Member Functions | |
| __construct () | |
| __destruct () | |
| store ($object, $cachename='') | |
| retrieve ($class, $time_limit=0) | |
Protected Member Functions | |
| getCachePath ($name) | |
Protected Attributes | |
| $basepath = '' | |
| $sizelimit = 0 | |
| $timeout = 0 | |
Static Private Attributes | |
| static | $mops = array() |
Definition at line 117 of file objectcache.php.
| aliroBasicCache::__construct | ( | ) |
| aliroBasicCache::__destruct | ( | ) |
| aliroBasicCache::getCachePath | ( | $ | name | ) | [abstract, protected] |
Reimplemented in aliroSimpleCache, and aliroSingletonObjectCache.
Referenced by retrieve(), and store().
| aliroBasicCache::store | ( | $ | object, | |
| $ | cachename = '' | |||
| ) |
Definition at line 133 of file objectcache.php.
References getCachePath().
Referenced by aliroSimpleCache::save().
00133 { 00134 $path = $this->getCachePath($cachename ? $cachename : get_class($object)); 00135 if (is_object($object)) $object->aliroCacheTimer = time(); 00136 else { 00137 $givendata = $object; 00138 $object = new stdClass(); 00139 $object->aliroCacheData = $givendata; 00140 $object->aliroCacheTimer = -time(); 00141 } 00142 $s = serialize($object); 00143 $s .= md5($s); 00144 if (strlen($s) > $this->sizelimit) return false; 00145 $result = is_writeable(dirname($path)) ? @file_put_contents($path, $s, LOCK_EX) : false; 00146 if (!$result) @unlink($path); 00147 return $result; 00148 }
| aliroBasicCache::retrieve | ( | $ | class, | |
| $ | time_limit = 0 | |||
| ) |
Definition at line 150 of file objectcache.php.
References getCachePath().
Referenced by aliroSimpleCache::get().
00150 { 00151 // $timer = class_exists('aliroProfiler') ? new aliroProfiler() : null; 00152 $result = null; 00153 $path = $this->getCachePath($class); 00154 if (file_exists($path) AND ($string = @file_get_contents($path))) { 00155 $s = substr($string, 0, -32); 00156 $object = ($s AND (md5($s) == substr($string, -32))) ? unserialize($s) : null; 00157 if (is_object($object)) { 00158 $time_limit = $time_limit ? $time_limit : $this->timeout; 00159 $stamp = @$object->aliroCacheTimer; 00160 if ((time() - abs($stamp)) <= $time_limit) $result = $stamp > 0 ? $object : @$object->aliroCacheData; 00161 } 00162 // if ($object AND $timer) echo "<br />Loaded $class in ".$timer->getElapsed().' secs'; 00163 } 00164 return $result; 00165 }
aliroBasicCache::$mops = array() [static, private] |
Definition at line 118 of file objectcache.php.
aliroBasicCache::$basepath = '' [protected] |
Definition at line 119 of file objectcache.php.
aliroBasicCache::$sizelimit = 0 [protected] |
Reimplemented in aliroSimpleCache, and aliroSingletonObjectCache.
Definition at line 120 of file objectcache.php.
aliroBasicCache::$timeout = 0 [protected] |
Reimplemented in aliroSimpleCache, and aliroSingletonObjectCache.
Definition at line 121 of file objectcache.php.
1.5.5