Download the PHP package thecodingmachine/cache-utils without Composer
On this page you can find all versions of the php package thecodingmachine/cache-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thecodingmachine/cache-utils
More information about thecodingmachine/cache-utils
Files in thecodingmachine/cache-utils
Package cache-utils
Short Description Store file related cache items easily
License MIT
Informations about the package cache-utils
Why?
This package contains a number of utility classes to play with PSR-6 caches.
File bound cache
Most PHP cache systems (like PSR-6 or PSR-16) are storing items in cache and attributing to items a time to live (TTL).
If you are developing a PHP framework or a PHP analysis library that relies a lot on reflection, it is quite common to have cache items that are related to PHP files or PHP classes.
For instance, Doctrine Annotations in a class do not change unless the class file(s) is changed. Therefore, it makes sense to bind the cache invalidation to the modification date of the file. thecodingmachine/cache-utils provides just that.
You can also use the FileBoundMemoryAdapter
to store the cache in memory for even faster access in the same query.
Class bound cache
You can also bind a cache item to a class / trait / interface using the ClassBoundCache
class.
The cache will expire if the class / trait / interface is modified.
The ClassBoundCache
constructor accepts 3 additional parameters:
$analyzeParentClasses
: if set to true, the cache will be invalidated if one of the parent classes is modified$analyzeTraits
: if set to true, the cache will be invalidated if one of the traits is modified$analyzeInterfaces
: if set to true, the cache will be invalidated if one of the interfaces implemented is modified
You can also use the ClassBoundMemoryAdapter
to store the cache in memory for even faster access in the same query.
Easier interface with cache contracts
You can even get an easier to use class bound cache using the ClassBoundCacheContract
.
With cache contracts, there is not setters. Only a getter that takes in parameter a callable that will resolve the cache item if the item is not available in the cache.