Exemple #1
0
 /**
  * @param  null|array $arguments Must be serializable.
  * @return void
  */
 public function warm($arguments = null)
 {
     $callable = $this->callable;
     if (is_array($arguments)) {
         $value = call_user_func_array($callable, $arguments);
     } else {
         $value = $callable();
     }
     $cacheKey = Cache::makeCacheKey($this->name, $arguments);
     $this->storage->addItem($cacheKey, serialize($value));
 }
Exemple #2
0
 public function testExpireExpiresCacheFromStorageEvenWithoutOperationDefinition()
 {
     $Cache = new Cache(array('adapter' => 'memory'));
     $Cache->cache('slowOperation', function () {
         return 'value';
     });
     $storage = $Cache->getStorage();
     $this->assertTrue($storage->hasItem(Cache::makeCacheKey('slowOperation')));
     $Cache->expire('slowOperation');
     $this->assertFalse($storage->hasItem(Cache::makeCacheKey('slowOperation')));
 }