Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function store($key, $value, $ttl = 0)
 {
     $key = $this->createKeyArray($key);
     $ttl = time() + $ttl;
     if ($this->cache->storeData($key, $value, $ttl) === false) {
         return false;
     }
 }
Esempio n. 2
0
 private function executeSet($data, $time)
 {
     if ($this->isDisabled()) {
         return false;
     }
     if (!isset($this->key)) {
         return false;
     }
     $store = array();
     $store['return'] = $data;
     $store['createdOn'] = time();
     if (isset($time)) {
         if ($time instanceof \DateTime) {
             $expiration = $time->getTimestamp();
             $cacheTime = $expiration - $store['createdOn'];
         } else {
             $cacheTime = isset($time) && is_numeric($time) ? $time : self::$cacheTime;
         }
     } else {
         $cacheTime = self::$cacheTime;
     }
     $expiration = $store['createdOn'] + $cacheTime;
     if ($cacheTime > 0) {
         $expirationDiff = rand(0, floor($cacheTime * 0.15));
         $expiration -= $expirationDiff;
     }
     if ($this->stampedeRunning == true) {
         $spkey = $this->key;
         $spkey[0] = 'sp';
         // change "cache" data namespace to stampede namespace
         $this->driver->clear($spkey);
         $this->stampedeRunning = false;
     }
     return $this->driver->storeData($this->key, $store, $expiration);
 }