Skip to content

Commit 771948e

Browse files
committed
feat: add emember() to CacheInterface
1 parent 455068a commit 771948e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

system/Cache/CacheInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace CodeIgniter\Cache;
1515

16+
use Closure;
17+
1618
interface CacheInterface
1719
{
1820
/**
@@ -37,6 +39,16 @@ public function get(string $key): mixed;
3739
* @return bool Success or failure
3840
*/
3941
public function save(string $key, mixed $value, int $ttl = 60): bool;
42+
43+
/**
44+
* Attempts to get an item from the cache, or executes the callback
45+
* and stores the result on cache miss.
46+
*
47+
* @param string $key Cache item name
48+
* @param int $ttl Time To Live, in seconds
49+
* @param Closure(): mixed $callback Callback executed on cache miss
50+
*/
51+
public function remember(string $key, int $ttl, Closure $callback): mixed;
4052

4153
/**
4254
* Deletes a specific item from the cache store.

0 commit comments

Comments
 (0)