Download the PHP package amne/simple-cache-layers without Composer
On this page you can find all versions of the php package amne/simple-cache-layers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amne/simple-cache-layers
More information about amne/simple-cache-layers
Files in amne/simple-cache-layers
Package simple-cache-layers
Short Description PSR16 implementation that reads and writes to a layered cache built from other PSR16 implementations
License MIT
Homepage https://github.com/amne/simple-cache-layers
Informations about the package simple-cache-layers
What?
This is a PSR-16 implementation of a layered cache that is full of optimism. It assumes the cache is being used for speed and not for important things like throttling, sessions or things like that.
How?
Layers are also PSR-16 implementations. This means every method of the layered cache is delegated to all the layers depending on the desired outcome:
get()andgetMultiple()will return a value from the first layer that has it. When a value is found in a "lower" layer it gets synced back up to all the "higher" layersset()andsetMultiple()will store a value in all the layers, starting from the "lowest" layer- a companion key suffixed with
-layer-metais created for all stored keys to keep track of creation time and first TTL. This information is used during sync back. - full of optimism: when things fail there is no rollback logic. If you set a key and it fails in a mid layer it just stops. This should be fine because
set()starts with the lowest layer and the nextget()will trigger a sync back
Why?
In a distributed context it can become a bottleneck to go out on the network to read a centralized cache all the time. Storing some information locally (in APC or even filesystem) with a short TTL should keep things going almost as fast as having everything cached only locally but still keep the control that a centralized cache like redis/memcache/couchbase gives you.