cache() public method

As a third argument - instead of integer - you can pass Ttt object to define grace tll and lock ttl (both optional).
public cache ( $key, callable $cachedCallable, $ttl, callable $onNoStaleCacheCallable = null )
$cachedCallable callable
$onNoStaleCacheCallable callable
Ejemplo n.º 1
0
 public function testCallableCanReturnDifferentValueIfNotStaleContentAvailableToServe()
 {
     $cache = new Cache(new MockStore());
     $customValue = 'custom_value';
     $cache->onNoStaleCache(function (NoStaleCacheEvent $event) use($customValue) {
         $event->setResult($customValue);
     });
     $key = 'lamela';
     $value = 'Tottenham Rabona';
     $ttl = 30;
     // simulate lock (other process generating content)
     $cache->getLockManager()->acquire($key, 30);
     $result = $cache->cache($key, $this->createFunc($value), $ttl);
     $this->assertSame($customValue, $result);
 }
Ejemplo n.º 2
0
 /**
  * @see CacheAdapterInterface::cache()
  */
 public function cache($key, callable $callable, $ttl)
 {
     return $this->backend->cache($this->prefix . $key, $callable, $ttl);
 }