diff --git a/src/Illuminate/Cache/ApcStore.php b/src/Illuminate/Cache/ApcStore.php index 90132c16f45f..5779635b203b 100755 --- a/src/Illuminate/Cache/ApcStore.php +++ b/src/Illuminate/Cache/ApcStore.php @@ -41,11 +41,7 @@ public function __construct(ApcWrapper $apc, $prefix = '') */ public function get($key) { - $value = $this->apc->get($this->prefix.$key); - - if ($value !== false) { - return $value; - } + return $this->apc->get($this->prefix.$key); } /** diff --git a/src/Illuminate/Cache/ApcWrapper.php b/src/Illuminate/Cache/ApcWrapper.php index 6c129c633288..8f6ce488180f 100755 --- a/src/Illuminate/Cache/ApcWrapper.php +++ b/src/Illuminate/Cache/ApcWrapper.php @@ -29,7 +29,9 @@ public function __construct() */ public function get($key) { - return $this->apcu ? apcu_fetch($key) : apc_fetch($key); + $fetchedValue = $this->apcu ? apcu_fetch($key, $success) : apc_fetch($key, $success); + + return $success ? $fetchedValue : null; } /** diff --git a/tests/Cache/CacheApcStoreTest.php b/tests/Cache/CacheApcStoreTest.php index fed3a9dc8cc1..e13d2adf63ec 100755 --- a/tests/Cache/CacheApcStoreTest.php +++ b/tests/Cache/CacheApcStoreTest.php @@ -25,6 +25,14 @@ public function testAPCValueIsReturned() $this->assertSame('bar', $store->get('foo')); } + public function testAPCFalseValueIsReturned() + { + $apc = $this->getMockBuilder(ApcWrapper::class)->onlyMethods(['get'])->getMock(); + $apc->expects($this->once())->method('get')->willReturn(false); + $store = new ApcStore($apc); + $this->assertFalse($store->get('foo')); + } + public function testGetMultipleReturnsNullWhenNotFoundAndValueWhenFound() { $apc = $this->getMockBuilder(ApcWrapper::class)->onlyMethods(['get'])->getMock();