I'm looking for the following caching behavior, quite similar to cache tags but with a twist.
Let's pretend there's a cache method called keywords()
. Consider the following code:
Cache::keywords(['user', 'general'])->put('key1', $value1, $minutes);
Cache::keywords('general')->put('key2', $value2, $minutes2);
This would store $value1
in key1
and $value2
in key2
, and they are both "marked" by their corresponding keywords.
Now here's the difference with cache tags: the keywords aren't ordered or constraining any following fluent calls. For example:
// Fetches value of key1, keywords are NOT required.
Cache::get('key1');
// Fetches value of key2, keywords are NOT required.
Cache::get('key2');
// Deletes all records using this keyword, viz. key1.
// key1 is completely out of cache storage, despite its other keyword.
Cache::keywords('user')->flush();
// Deletes all records using this keyword, viz. key1 and key2.
// key1 is completely out of cache storage, despite its other keyword.
Cache::keywords('general')->flush();
Is this possible out-of-the-box in Laravel?
If not, how could this be approached so that it is generic to all cache drivers?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire