perturbatio / wildcache
Installs: 1 954
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- illuminate/cache: ^6|^7|^8|^9
- illuminate/support: ^6|^7|^8|^9
Requires (Dev)
- orchestra/testbench: ^6.0|^7.7
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-10-29 05:47:49 UTC
README
Adds the ability to find or remove items in the Laravel cache by wildcard.
Usage
Using WildCache, you can store items using a dot.notation
syntax, then retrieve the item
matching to get or remove all items matching a pattern.
Methods
Put - Write a value to cache
/** @var \Perturbatio\WildCache\WildCache $wildCache */ $wildCache = app('wildcache'); // use the WildCache to store the item with a dot separated key $wildCache->put('test.WildCache.itemA', 9999, now()->addMinutes(10)); $wildCache->put('test.WildCache.itemB', 8888, now()->addMinutes(10));
Get
The get method always returns a collection of any items that match the pattern, or the default value passed in
(defaults to null
)
/** @var \Perturbatio\WildCache\WildCache $wildCache */ $wildCache = app('wildcache'); // returns the first item that has a key prefixed with `test.WildCache.` echo $wildCache->get('test.WildCache.*')->first();
/** @var \Perturbatio\WildCache\WildCache $wildCache */ $wildCache = app('wildcache'); echo $wildCache->get('some.key', 'default_value')->first();
/** @var \Perturbatio\WildCache\WildCache $wildCache */ $wildCache = app('wildcache'); // use the WildCache to store the item with a dot separated key $wildCache->put('test.WildCache.itemA', 9999, now()->addMinutes(10)); $wildCache->put('test.WildCache.itemB', 8888, now()->addMinutes(10)); // retrieve the first that matches the key echo $wildCache->get('test.WildCache.*')->first(); // 9999 echo $wildCache->get('test.WildCache.*')->get('wildcache.test.itemB');