From 771948ea01082c25488053eb50e1ba6fa74953b4 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 8 Jan 2026 10:47:14 +0330 Subject: [PATCH 1/4] feat: add emember() to CacheInterface --- system/Cache/CacheInterface.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index 9ae83f29283d..6241a0365934 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Cache; +use Closure; + interface CacheInterface { /** @@ -37,6 +39,16 @@ public function get(string $key): mixed; * @return bool Success or failure */ public function save(string $key, mixed $value, int $ttl = 60): bool; + + /** + * Attempts to get an item from the cache, or executes the callback + * and stores the result on cache miss. + * + * @param string $key Cache item name + * @param int $ttl Time To Live, in seconds + * @param Closure(): mixed $callback Callback executed on cache miss + */ + public function remember(string $key, int $ttl, Closure $callback): mixed; /** * Deletes a specific item from the cache store. From 2e830335fd5cce4c0087691e5ffcc29b55f4c142 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 8 Jan 2026 10:53:35 +0330 Subject: [PATCH 2/4] docs: note addition of emember() to CacheInterface --- user_guide_src/source/changelogs/v4.7.0.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.7.0.rst b/user_guide_src/source/changelogs/v4.7.0.rst index 2355e9a9f420..18012daf4874 100644 --- a/user_guide_src/source/changelogs/v4.7.0.rst +++ b/user_guide_src/source/changelogs/v4.7.0.rst @@ -116,6 +116,8 @@ Interface Changes - **Cache:** The ``CacheInterface`` now includes the ``deleteMatching()`` method. If you've implemented your own caching driver from scratch, you will need to provide an implementation for this method to ensure compatibility. - **Images:** The ``ImageHandlerInterface`` now includes a new method: ``clearMetadata()``. If you've implemented your own handler from scratch, you will need to provide an implementation for this method to ensure compatibility. +- **Cache:** The ``CacheInterface`` now includes the ``remember()`` method. All built-in cache handlers inherit this method via ``BaseHandler``, so no changes are required for them. +If you have implemented your own caching driver directly from ``CacheInterface``, you will need to provide an implementation for ``remember()`` to maintain compatibility. Method Signature Changes ======================== From 35cb5bfe497bfd80637f6426fd4d4aabdf13b5a4 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 8 Jan 2026 11:00:41 +0330 Subject: [PATCH 3/4] style: fix code style --- system/Cache/CacheInterface.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index 6241a0365934..4cedb67e9538 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -39,13 +39,13 @@ public function get(string $key): mixed; * @return bool Success or failure */ public function save(string $key, mixed $value, int $ttl = 60): bool; - + /** * Attempts to get an item from the cache, or executes the callback * and stores the result on cache miss. * - * @param string $key Cache item name - * @param int $ttl Time To Live, in seconds + * @param string $key Cache item name + * @param int $ttl Time To Live, in seconds * @param Closure(): mixed $callback Callback executed on cache miss */ public function remember(string $key, int $ttl, Closure $callback): mixed; From 28c56cf0cb7a0de49afebe65f14e1fc9fd9ddfc6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 8 Jan 2026 11:05:23 +0330 Subject: [PATCH 4/4] docs: fix UG style --- user_guide_src/source/changelogs/v4.7.0.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.7.0.rst b/user_guide_src/source/changelogs/v4.7.0.rst index 18012daf4874..0b647c693a62 100644 --- a/user_guide_src/source/changelogs/v4.7.0.rst +++ b/user_guide_src/source/changelogs/v4.7.0.rst @@ -116,8 +116,7 @@ Interface Changes - **Cache:** The ``CacheInterface`` now includes the ``deleteMatching()`` method. If you've implemented your own caching driver from scratch, you will need to provide an implementation for this method to ensure compatibility. - **Images:** The ``ImageHandlerInterface`` now includes a new method: ``clearMetadata()``. If you've implemented your own handler from scratch, you will need to provide an implementation for this method to ensure compatibility. -- **Cache:** The ``CacheInterface`` now includes the ``remember()`` method. All built-in cache handlers inherit this method via ``BaseHandler``, so no changes are required for them. -If you have implemented your own caching driver directly from ``CacheInterface``, you will need to provide an implementation for ``remember()`` to maintain compatibility. +- **Cache:** The ``CacheInterface`` now includes the ``remember()`` method. All built-in cache handlers inherit this method via ``BaseHandler``, so no changes are required for them. If you have implemented your own caching driver directly from ``CacheInterface``, you will need to provide an implementation for ``remember()`` to maintain compatibility. Method Signature Changes ========================