Example #1
0
 /**
  * @param CacheKey $key
  * @depreciated
  */
 public function clearModule(CacheKey $key)
 {
     $module = $key->getModule();
     $iterator = new \APCIterator('user');
     while ($iterator->current()) {
         $tKey = $iterator->key();
         if (mb_strpos($tKey, $module . '||') !== false) {
             apc_delete($tKey);
         }
         $iterator->next();
     }
 }
Example #2
0
 public function cacheKey()
 {
     return CacheKey::create()->dependOnPath()->dependOnRequestParameter(self::acceptedRequestParams());
 }
Example #3
0
 public function set(CacheKey $key, $value, $sessionLength = null)
 {
     $module = $key->getModule();
     $property = $key->getProperty();
     if ($sessionLength == null) {
         $sessionLength = $this->timeThreshold;
     }
     if (!isset($this->elements[$module][$property])) {
         $this->elements[$module][$property] = new FileElement($value, time() + $sessionLength);
     } else {
         /** @noinspection PhpUndefinedMethodInspection */
         $this->elements[$module][$property]->set($value, time() + $sessionLength);
     }
     if (!isset($_SESSION[$this->cacheMaintenanceTimeName][$module])) {
         $_SESSION[$this->cacheMaintenanceTimeName][$module] = time() + $sessionLength;
     }
     $this->changed = true;
 }
 /**
  * Unset cache value
  * @param CacheKey $key
  */
 public function clear(CacheKey $key)
 {
     unset($this->cache[$key->getModule()][$key->getProperty()]);
 }
 /**
  * @param CacheKey $key
  * @return string
  */
 protected function getKey(CacheKey $key)
 {
     return static::$sCachePrefix . '__' . $key->getModule() . '||' . $key->getProperty();
 }
Example #6
0
 /**
  * Logs cache accesses for debugging
  *
  * @param string $status CacheLogEnum constant
  * @param CacheKey $k The message to print.
  * @param integer $lifetime
  * @codeCoverageIgnore
  */
 protected function log($status, CacheKey $k, $lifetime = 0)
 {
     static::$summary[$status]++;
     if ($this->should_log == false) {
         return;
     }
     $bt = debug_backtrace();
     foreach ($bt as $i => $d) {
         if (strpos($d['file'], '/Cache') === false) {
             // TODO: if() may not work well if user has a file called Cache
             $trace = $d['function'] . ' at ' . $d['file'] . ':' . $d['line'];
             $this->cache_log[] = array('status' => $status, 'message' => "(" . $k->debug() . ", {$lifetime}) by " . $trace);
             break;
         }
     }
 }
Example #7
0
 public function clear(CacheKey $key)
 {
     $module = $key->getModule();
     $id = $key->getProperty();
     if (!empty($id)) {
         unset($_SESSION[$this->cacheName][$module][$id]);
     } else {
         unset($_SESSION[$this->cacheName][$module]);
     }
 }