This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test to check TTL on set/setMultiple of SimpleCacheDecorator
We should use TTL from options when it is not provided on set/setMultiple methods of SimpleCacheDecorator.
- Loading branch information
1 parent
035b012
commit 96fa750
Showing
2 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-cache for the canonical source repository | ||
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com) | ||
* @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
namespace ZendTest\Cache\Psr\SimpleCache\TestAsset; | ||
|
||
use Zend\Cache\Storage\Adapter; | ||
use Zend\Cache\Storage\Capabilities; | ||
|
||
class TtlStorage extends Adapter\AbstractAdapter | ||
{ | ||
/** @var array */ | ||
private $data = []; | ||
|
||
/** @var array */ | ||
public $ttl = []; | ||
|
||
protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null) | ||
{ | ||
$success = isset($this->data[$normalizedKey]); | ||
|
||
return $success ? $this->data[$normalizedKey] : null; | ||
} | ||
|
||
protected function internalSetItem(& $normalizedKey, & $value) | ||
{ | ||
$this->ttl[$normalizedKey] = $this->getOptions()->getTtl(); | ||
|
||
$this->data[$normalizedKey] = $value; | ||
return true; | ||
} | ||
|
||
protected function internalRemoveItem(& $normalizedKey) | ||
{ | ||
unset($this->data[$normalizedKey]); | ||
return true; | ||
} | ||
|
||
public function setCapabilities(Capabilities $capabilities) | ||
{ | ||
$this->capabilities = $capabilities; | ||
} | ||
} |