Skip to content

Adds the ability to find or remove items in the Laravel cache by wildcard

License

Notifications You must be signed in to change notification settings

Perturbatio/WildCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WildCache

CircleCI Latest Stable Version Latest Unstable Version License Total Downloads

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');

About

Adds the ability to find or remove items in the Laravel cache by wildcard

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages