Download the PHP package trevorpe/laravel-symfony-cache without Composer
On this page you can find all versions of the php package trevorpe/laravel-symfony-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trevorpe/laravel-symfony-cache
More information about trevorpe/laravel-symfony-cache
Files in trevorpe/laravel-symfony-cache
Package laravel-symfony-cache
Short Description Use Symfony's Cache bundle with Laravel
License MIT
Informations about the package laravel-symfony-cache
laravel-symfony-cache
Use the Symfony Cache Component with Laravel's cache system. Heavily inspired by the alternative-laravel-cache project.
[!CAUTION] Symfony's Cache component behaves differently than Laravel's.
Read the Clear Behavior sections before replacing the default Laravel cache stores with this library, and consider how a different tag behavior could affect any other libraries that you use.
Requirements
- Laravel 10.x or greater
- Symfony Cache 7.2 or greater
Installation
Usage
This library introduces a new cache driver registered with Laravel's CacheManager
.
You can use a Symfony cache
adapter by specifying symfony
as your cache driver alongside an adapter
property, with the fully-qualified class
name of the Symfony cache adapter you'd like to use.
Configuration Examples
Array
Filesystem
Filesystem (Tagged)
Redis
Redis (Tagged)
Tag Behavior
Similar to alternative-laravel-cache, this library brings an alternate tag behavior than Laravel's default cache.
Symfony's cache system does not treat tags as hierarchical like Laravel's cache system does. Instead,
tagging a cache entry with one or more tags allows you to invalidate a group
of entries all at once by referencing its tag. In addition, each tag is applied
individually, rather than as an ordered list. (E.g. applying two tags and calling flush()
with either of
those tags will invalidate the entry.)
This means that tagging is only really useful when writing or removing data. Reading tagged data will function identically to getting a cache entry by its key without tags.
Examples
Clear Behavior
The clear()
method of Laravel will clear the entire cache when using Redis as the driver (and possibly others).
With Symfony's cache system, clear()
will only clear keys matching the prefix and namespace. This is a bit less
dangerous, but one should be still be cautious when clearing a cache store to ensure you are only deleting
the intended values.
All versions of laravel-symfony-cache with dependencies
laravel/framework Version ^10.0 || ^11.0
symfony/cache Version ^6.0 || ^7.0