public function testShouldReturnNullFlushRecord()
 {
     $this->repository->add('memcached-testing', 'couchbase', 60);
     $this->repository->decrement('memcached-testing-decrement', 100);
     $this->repository->increment('memcached-testing-increment', 100);
     $this->repository->flush();
     $this->assertNull($this->repository->get('memcached-testing'));
     $this->assertNull($this->repository->get('memcached-testing-decrement'));
     $this->assertNull($this->repository->get('memcached-testing-increment'));
 }
 /**
  * {@inheritdoc}
  */
 public function save($key, CacheEntry $data)
 {
     try {
         $lifeTime = $data->getTTL();
         if ($lifeTime === 0) {
             return $this->cache->forever($key, serialize($data));
         } else {
             if ($lifeTime > 0) {
                 return $this->cache->add($key, serialize($data), $lifeTime);
             }
         }
     } catch (\Exception $ignored) {
         // No fail if we can't save it the storage
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Return result values
  *
  * @param array  $results
  * @param string $key
  *
  * @return string|array
  */
 protected function returnResults($results, $key)
 {
     if ($results && count($results) > 1) {
         $results = $this->arrangeResults($results, $key);
         $this->cache->add($this->attachTag($key), $results, $this->expiry);
         return $results;
     }
     if ($results) {
         $result = @json_decode($results[$key]) ?: $results[$key];
         $this->cache->add($this->attachTag($key), $result, $this->expiry);
         return $result;
     }
 }
Esempio n. 4
0
 /**
  * Store an item in the cache if the key does not exist.
  *
  * @param string $key
  * @param mixed $value
  * @param \DateTime|int $minutes
  * @return bool 
  * @static 
  */
 public static function add($key, $value, $minutes)
 {
     return \Illuminate\Cache\Repository::add($key, $value, $minutes);
 }
Esempio n. 5
0
 /**
  * Store an item in the cache if the key does not exist.
  *
  * @param  mixed  $key
  * @param  mixed  $value
  * @param  \DateTime|int  $minutes
  * @return mixed
  */
 public function add($key, $value, $minutes)
 {
     if (is_array($key) && is_array($value)) {
         return $this->addMany(array_combine($key, $value), $minutes);
     }
     return parent::add($key, $value, $minutes);
 }
 /**
  * Store an item in the cache if the key does not exist.
  *
  * @param  string        $key
  * @param  mixed         $value
  * @param  \DateTime|int $minutes
  * @return bool
  * @throws \Propaganistas\LaravelCacheKeywords\Exceptions\ReservedCacheKeyPatternException
  */
 public function add($key, $value, $minutes)
 {
     $this->checkReservedKeyPattern($key);
     $this->setKeywordsOperation(true);
     if ($result = parent::add($key, $value, $minutes)) {
         $this->storeKeywords($key, $minutes, $this->keywords);
     }
     $this->setKeywordsOperation(false);
     $this->resetCurrentKeywords();
     return $result;
 }
Esempio n. 7
0
 /**
  * Store an item in the cache if the key does not exist.
  *
  * @param  string        $key
  * @param  mixed         $value
  * @param  \DateTime|int $minutes
  *
  * @return bool
  */
 public function add($key, $value, $minutes)
 {
     return $this->enabled ? $this->cache->add($key, $value, $minutes) : false;
 }
Esempio n. 8
0
 /**
  * Set cache entry
  *
  * @param string $key
  * @param string $content
  *
  * @return void
  */
 public function setItem($key, $content)
 {
     $key = $this->getKey($key);
     $ttl = $this->configurationRepository->get('shariff.cache.ttl');
     $this->cacheRepository->add($key, $content, $ttl);
 }