Skip to content

Commit

Permalink
Merge pull request #5 from moufmouf/ttl_contract
Browse files Browse the repository at this point in the history
Adding TTL on cache contracts
  • Loading branch information
moufmouf committed Jun 14, 2019
2 parents 343b4b2 + 8f6025d commit c71f590
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ClassBoundCacheContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(ClassBoundCacheInterface $classBoundCache)
*
* @return mixed
*/
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '')
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '', ?int $ttl = null)
{
$cacheKey = $reflectionClass->getName() . '__' . $key;
$item = $this->classBoundCache->get($cacheKey);
Expand All @@ -31,7 +31,7 @@ public function get(ReflectionClass $reflectionClass, callable $resolver, string

$item = $resolver();

$this->classBoundCache->set($cacheKey, $item, $reflectionClass);
$this->classBoundCache->set($cacheKey, $item, $reflectionClass, $ttl);

return $item;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ClassBoundCacheContractInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ interface ClassBoundCacheContractInterface
*
* @return mixed
*/
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '');
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '', ?int $ttl = null);
}

0 comments on commit c71f590

Please sign in to comment.