Skip to content

Commit c71f590

Browse files
authored
Merge pull request #5 from moufmouf/ttl_contract
Adding TTL on cache contracts
2 parents 343b4b2 + 8f6025d commit c71f590

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/ClassBoundCacheContract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(ClassBoundCacheInterface $classBoundCache)
2121
*
2222
* @return mixed
2323
*/
24-
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '')
24+
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '', ?int $ttl = null)
2525
{
2626
$cacheKey = $reflectionClass->getName() . '__' . $key;
2727
$item = $this->classBoundCache->get($cacheKey);
@@ -31,7 +31,7 @@ public function get(ReflectionClass $reflectionClass, callable $resolver, string
3131

3232
$item = $resolver();
3333

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

3636
return $item;
3737
}

src/ClassBoundCacheContractInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ interface ClassBoundCacheContractInterface
1313
*
1414
* @return mixed
1515
*/
16-
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '');
16+
public function get(ReflectionClass $reflectionClass, callable $resolver, string $key = '', ?int $ttl = null);
1717
}

0 commit comments

Comments
 (0)