cache/taggable-cache
Adapter that makes any PSR-6 cache pool taggable. Tag related cache items and invalidate them by tag without clearing the whole cache. Part of the PHP Cache organization; works with all PHP Cache pools supporting tagging.
Start by installing the package via Composer:
composer require cache/taggable-cache
This package provides a decorator that wraps any PSR-6 pool to add tagging support — it does not implement caching itself. First, instantiate a base PSR-6 pool (e.g., PhpBuffersPool, ArrayPool, or a Doctrine/Filesystem pool), then wrap it with Cache\Taggable\TaggableCachePool. Example:
$pool = new \Cache\Taggable\TaggableCachePool(new \Cache\Adapter\ ArrayAdapter());
$pool->save($pool->getItem('user:123')->set($userData)->tag(['users', 'profile']));
The most common first use case is caching entities by ID with associated tags (e.g., post:42 tagged with posts, author:5) to enable invalidating all posts by author 5 later.
save() or saveDeferred() — tags are attached via ItemInterface::tag(['tag1', 'tag2']).TaggableCachePool::clearTags(['tag1', 'tag2']) to evict all items with matching tags.model:Post:123, author:5) to simulate grouping.Cache::driver()->getStore()) in a TaggableCachePool and inject it where tagging is needed (though native Cache::tags() is preferred in Laravel unless special tagging behavior is required).commit() after saveDeferred(), and tags are stored persistently with the item.php-cache/filesystem, php-cache/apcu, or symfony/cache (via Symfony\Component\Cache\Adapter\ArrayAdapter).null throw InvalidArgumentException. Normalize tag names consistently (e.g., mb_strtolower, slugify).getItem, save, etc., behave normally, but clearTags() is the only non-standard method.commit() — if the script exits before commit, tags are lost.save() with tags).php-cache/cache or PSR-16 (simple cache) alternatives like symfony/cache with tags (though PSR-16 doesn’t standardize tags).How can I help you explore Laravel packages today?