perturbatio/wildcache

2,111 2
Install
composer require perturbatio/wildcache
Latest Version:v2.0.4
License:MIT
Last Updated:Aug 29, 2022
Links: GitHub  ·  Packagist
Maintainer: Perturbatio

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

Related Packages

spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

9,913,623 2,816
barryvdh/laravel-httpcache

HttpCache for Laravel

411,082 502
ytake/laravel-smarty

Smarty template engine for Laravel and Lumen

415,086 85
ytake/laravel-couchbase

Couchbase providers for Laravel

52,496 30
maartenstaa/laravel-41-route-caching

This package allows you to cache your routes definitions, thereby speeding up ea...

386,594 25