Download the PHP package sci/cacheable without Composer
On this page you can find all versions of the php package sci/cacheable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download sci/cacheable
More information about sci/cacheable
Files in sci/cacheable
Download sci/cacheable
More information about sci/cacheable
Files in sci/cacheable
Please rate this library. Is it a good library?
Informations about the package cacheable
Cacheable – A transparent caching library
Installation
Using composer:
Usage
Lets say, you have a class Foo, implementing a method Foo::bar() with quite high time/resource consumption:
If there are no side-effects, the result of Foo::bar() is determined only by its arguments $a and $b.
So you could use some cache, if eventuelly the method is called again.
To avoid messing around with cache keys, you can use sci\cacheable:
en détail
- A class to be cached (
Fooin example above) implements the interfaceSci\Cacheable(which demands a methodcache()). - This can be done using
Sci\CacheTrait(which additially provides a methodsetCache()). - The method
setCachegets as first argument a service, implementingPsr\Cache\CacheItemPoolInterface.- This cache pool is the actual cache backend.
- An optional second argument to
setCacheis the default TTL (time to live) for all cached values.
- To use the cache, method calls are proxied through the method
cache(), e.g. instead of$foo->bar(1, 2), now we use$foo->cache()->bar(1, 2).- Method
cache()returns$this, i.e. it acts in a transparent way (fluent interface). - An optional argument for
cache()allows to specify a TTL, different from the default one.
- Method
Implementation
License
All contents of this package are licensed under the MIT license.
All versions of cacheable with dependencies
PHP Build Version
Package Version
The package sci/cacheable contains the following files
Loading the files please wait ...
