Skip to content

Commit

Permalink
fix empty cache issue in interceptor (#4)
Browse files Browse the repository at this point in the history
* fix empty cache issue in interceptor

* fix empty cache issue in interceptor
  • Loading branch information
alexbumbacea committed Oct 13, 2016
1 parent 52ee084 commit 22c95f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/CacheBundle/DependencyInjection/Interceptor.php
Expand Up @@ -17,6 +17,10 @@ class Interceptor implements MethodInterceptorInterface, LoggerAwareInterface

/** @var LoggerInterface */
protected $logger;
/** @var Reader */
protected $reader;
/** @var AbstractCache */
protected $cacheService;

/** @var array */
private $cacheData;
Expand Down Expand Up @@ -45,20 +49,15 @@ public function intercept(MethodInvocation $invocation)


if ($cacheObj->isReset() || ($this->getCacheFlags($invocation->reflection) & Cache::STATE_RESET)) {
$data = null;
$data = false;
} else {
$data = $this->cacheService->get($cacheKey);
}

if ($data) {
if ($data !== false) {
$this->logger->debug('Cache hit for ' . $cacheKey);
return $data;
}

if ($cacheObj->isReset() || ($this->getCacheFlags($invocation->reflection) & Cache::STATE_RESET)) {
$this->logger->debug('Cache reset for ' . $cacheKey);
} else {
$this->logger->debug('Cache miss for ' . $cacheKey);
return $data;
}

$result = $invocation->proceed();
Expand Down
2 changes: 0 additions & 2 deletions src/CacheBundle/Tests/CacheWrapperTest.php
Expand Up @@ -47,8 +47,6 @@ public function testWithMultiParams()
$object = $this->container->get('cache.testservice');
$result = $object->testWithMultipleParams(200, 300);

$logHandler = $this->getLogHandler();

$this->assertEquals($result, $object->testWithMultipleParams(200, 300));
$this->assertEquals($result, $object->testWithMultipleParams(200, 150));
$this->assertEquals($result, $object->testWithMultipleParams(200, 150, 100));
Expand Down

0 comments on commit 22c95f8

Please sign in to comment.