Download the PHP package yii1tech/psr-cache without Composer
On this page you can find all versions of the php package yii1tech/psr-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package psr-cache
Yii1 PSR-6 Cache Extension
This extension allows integration with PSR-6 compatible cache for Yii1.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the "require" section of your composer.json.
Usage
This extension allows integration with PSR-6 compatible cache for Yii1. It provides several instruments for that. Please choose the one suitable for your particular needs.
Wrap PSR cache pool into Yii cache
The most common use case for PSR cache involvement into Yii application is usage of 3rd party cache library.
This can be achieved using \yii1tech\psr\cache\Cache
as Yii cache component.
Application configuration example:
Wrap Yii cache into PSR cache pool
There is another use case related to PSR cache besides bootstrapping external cache storage.
Sometimes 3rd party libraries may require PSR cache pool instance to be passed to them in order to function.
\Psr\Cache\CacheItemPoolInterface
allows wrapping standard Yii cache component into a PSR compatible cache pool.
Application configuration example:
Usage example:
Extended interface
This extension introduces 2 interfaces, which extend the ones from PSR-6:
\yii1tech\psr\cache\CacheItemPoolContract
\yii1tech\psr\cache\CacheItemContract
These interfaces could be used to utilize additional functionality, which is omitted at PSR. In particular these allow usage of Yii cache dependency feature. For example:
In addition, \yii1tech\psr\cache\CacheItemPoolContract
declares method get()
, which can be used to simplify usage
of the cache pool, making it similar to Symfony.
For example:
Using cache tags
This extension allows setup of tags per each particular cache items via \yii1tech\psr\cache\CacheItemContract::tag()
method.
Heads up! This package does not directly implement cache tags feature - it does rely on wrapped Yii cache component to support it instead.
All tags associated with the cache item are passed as 5th argument to \ICache::set()
method, assuming its particular implementation will
handle them. Thus cache item tags saving will silently fail if related cache component does not provide support for it.
You may use yii1tech/tagged-cache extension to get a tag aware cache Yii component.
Application configuration example:
Tag specification example:
In order to clear items associated with particular tag use \yii1tech\psr\cache\CacheItemPoolContract::invalidateTags()
.
For example: