Skip to content

Commit 4da7098

Browse files
committed
Removed flushAllQueryCache and kept the flushQueryCache method with no parameters.
1 parent 5e89d16 commit 4da7098

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,10 @@ $bob = Kid::whereName('Bob')->cacheFor(60)->cacheTags(['kids'])->first();
9292

9393
### Global Cache Invalidation
9494

95-
To invalidate all the cache for a specific model, use the `flushAllQueryCache` method.
95+
To invalidate all the cache for a specific model, use the `flushQueryCache` method without any additional parameter.
9696

9797
The package automatically appends a list of tags, called **base tags** on each query coming from a model. It defaults to the full model class name.
9898

99-
You can still use your custom tags on the queries and they will work like usual:
100-
101-
```php
102-
Kid::flushAllQueryCache();
103-
```
104-
10599
In case you want to change the base tags, you can do so in your model.
106100

107101
```php
@@ -124,7 +118,7 @@ class Kid extends Model
124118
}
125119

126120
// Automatically works with `custom_tag`
127-
Kid::flushAllQueryCache();
121+
Kid::flushQueryCache();
128122
```
129123

130124
## Relationship Caching

src/Traits/QueryCacheModule.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,17 @@ public function flushQueryCache(array $tags = []): bool
171171
return false;
172172
}
173173

174+
if (! $tags) {
175+
$tags = $this->getCacheBaseTags();
176+
}
177+
174178
foreach ($tags as $tag) {
175179
self::flushQueryCacheWithTag($tag);
176180
}
177181

178182
return true;
179183
}
180184

181-
/**
182-
* Flush all cached resources with the default model tag.
183-
*
184-
* @return bool
185-
*/
186-
public function flushAllQueryCache(): bool
187-
{
188-
return self::flushQueryCache(
189-
$this->getCacheBaseTags() ?: []
190-
);
191-
}
192-
193185
/**
194186
* Flush the cache for a specific tag.
195187
*

tests/MethodsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function test_cache_flush_with_default_tags_attached()
9898
$cache = Cache::tags(['test', Book::getCacheBaseTags()[0]])->get('leqc:sqlitegetselect * from "books" limit 1a:0:{}');
9999
$this->assertNotNull($cache);
100100

101-
Book::flushAllQueryCache();
101+
Book::flushQueryCache();
102102

103103
$cache = Cache::tags(['test', Book::getCacheBaseTags()[0]])->get('leqc:sqlitegetselect * from "books" limit 1a:0:{}');
104104

0 commit comments

Comments
 (0)