/** * {@inheritdoc} */ public function get($key) { if (isset($this->hot[$key])) { return $this->hot[$key]; } return $this->hot[$key] = $this->cache->get($key); }
/** * @param string $method * @param array $arguments * @return mixed * @throws \RuntimeException */ public function __call($method, $arguments) { $reflection = new \ReflectionClass($this->decoratedObject); /* if (!$reflection->hasMethod($method)) { throw new \InvalidArgumentException('"' . $method . '" is not method of class ' . $reflection->name); } */ $key = CacheProvider::generateCacheKey($reflection->name, $method, md5(var_export($arguments, true))); $result = $this->cache->get($key); if ($result === false) { $result = call_user_func_array([$this->decoratedObject, $method], $arguments); $this->cache->add($key, $result, $this->ttl); } return $result; }
public function testFlush() { $this->cache->set('test', 'data'); $this->assertEquals('data', $this->cache->get('test')); $this->assertTrue($this->cache->flush()); $this->assertFalse($this->cache->get('data')); }