Skip to content

Commit 93155e7

Browse files
committed
fix taggable cache impl
1 parent 6f9f313 commit 93155e7

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,18 @@ php artisan flexible-content-block-pages:seed
5555

5656
Further configure the third-party packages that are used. Check the installation documentation of these packages:
5757

58-
- [Laravel Localization](https://github.com/mcamara/laravel-localization?tab=readme-ov-file#installation):
59-
Make sure the middlewares are properly setup if you want to use localised routes.
58+
### [Laravel Localization](https://github.com/mcamara/laravel-localization?tab=readme-ov-file#installation):
6059

60+
Make sure the middlewares are properly setup if you want to use localised routes.
61+
62+
### [Laravel Tags](https://spatie.be/docs/laravel-tags/v4/installation-and-setup):
63+
64+
Publish the config and change the tag model to the package model:
65+
```php
66+
[
67+
'tag_model' => \Statikbe\FilamentFlexibleContentBlockPages\Models\Tag::class,
68+
]
69+
```
6170

6271
Check [the configuration documentation}(#configuration) for more explanations on how to tweak the package.
6372

@@ -102,6 +111,16 @@ If you want you can build your own panel from the provided resources.
102111

103112
TODO
104113

114+
## TODO's
115+
116+
- policies:
117+
- note: undeletable pages
118+
- undeletable page toggle only for permission holder
119+
- redirect controller
120+
- tag controller
121+
- sitemap implementation
122+
- asset manager install in panel
123+
105124
## Changelog
106125

107126
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

src/Cache/TaggableCache.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@ public static function rememberForeverWithTag(string $tag, string $key, Closure
1313

1414
// add key to tag cache
1515
$keysWithTag = Cache::get($tag, []);
16-
$keysWithTag[] = $key;
17-
Cache::forever($tag, $keysWithTag);
16+
if (! in_array($key, $keysWithTag)) {
17+
$keysWithTag[] = $key;
18+
Cache::forever($tag, $keysWithTag);
19+
}
1820

1921
return $cachedValue;
2022
}
2123

2224
public static function flushTag(string $tag)
2325
{
26+
$taggedKeys = Cache::get($tag, []);
27+
foreach ($taggedKeys as $key) {
28+
Cache::forget($key);
29+
}
30+
2431
Cache::forget($tag);
2532
}
2633
}

0 commit comments

Comments
 (0)