Skip to content

Commit 340edc9

Browse files
committed
Fixes and improvements:
- Adds the ability to pass your keys to the clearCache method - Fixes importance of «nested-caching.disabled»
1 parent 6bb8358 commit 340edc9

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "slydeath/laravel-nested-caching",
33
"description": "Nested Caching for Laravel with caches stack",
44
"license": "MIT",
5-
"version": "1.0",
5+
"version": "1.1",
66
"authors": [
77
{
88
"name": "SlyDeath",

src/CacheStack.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,18 @@ public function setKey(string $key)
4444
}
4545

4646
/**
47-
* Clearing the current cache stack
47+
* Clearing cache stack
48+
*
49+
* @param string|array|null $keys Caching keys
4850
*
4951
* @return bool
5052
*
5153
* @throws \Psr\SimpleCache\InvalidArgumentException
5254
*/
53-
public function clearCache(): bool
55+
public function clearCache($keys = null): bool
5456
{
55-
$keys = $this->getKeys();
57+
$keys = $keys ?? $this->getKeys();
58+
5659
$this->keys = [];
5760

5861
return $this->cache->forget($keys);

src/NestedCachingServiceProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ public function checkCacheDriverSupport()
6060
*/
6161
public function applyMiddleware($kernel)
6262
{
63-
if (config('nested-caching.disabled') || in_array(app('env'), config('nested-caching.expelled-envs'), true)) {
63+
if ( ! config('nested-caching.disabled')) {
64+
return;
65+
}
66+
67+
if (in_array(app('env'), config('nested-caching.expelled-envs'), true)) {
6468
$kernel->pushMiddleware('SlyDeath\NestedCaching\FlushCacheMiddleware');
6569
}
6670
}

0 commit comments

Comments
 (0)