Skip to content

Commit

Permalink
change remember signature
Browse files Browse the repository at this point in the history
  • Loading branch information
salehhashemi1992 committed Dec 18, 2023
1 parent 16aba54 commit 341e921
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $value = ConfigurableCache::get('testKey', 'short');
ConfigurableCache::delete('testKey', 'otp');

// if `testKey` doesn't exist in the 'default' cache, the Closure will be executed and its result will be stored in the cache under `testKey` with `_default_` prefix
$value = ConfigurableCache::remember('testKey', 'default', function () {
$value = ConfigurableCache::remember('testKey', function () {
return 'Hello World!';
});
```
Expand Down
4 changes: 2 additions & 2 deletions src/ConfigurableCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class ConfigurableCache
* @template TCacheValue
*
* @param string $key The cache key to retrieve or store the item.
* @param string $config The cache configuration to use (e.g., 'default').
* @param \Closure(): TCacheValue $callback The Closure to execute if the item is not found in the cache.
* @param string $config The cache configuration to use (e.g., 'default').
* @return TCacheValue The cached item or the result of the Closure execution.
*/
public static function remember(string $key, string $config, Closure $callback): mixed
public static function remember(string $key, Closure $callback, string $config = 'default'): mixed
{
$cacheKey = static::cacheKey($key, $config);
$ttl = static::ttl($config);
Expand Down
2 changes: 1 addition & 1 deletion tests/ConfigurableCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function test_increment_function_increments_cache_value()

public function test_remember_function_stores_closure_result_in_cache()
{
ConfigurableCache::remember('testKey', 'default', function () {
ConfigurableCache::remember('testKey', function () {
return 'testValue';
});

Expand Down

0 comments on commit 341e921

Please sign in to comment.