yii2-extended / yii2-psr16-simple-cache-bridge
A library to bridge psr-16 simple caches with the yii caching system
Requires
- php: >=8.0
- psr/simple-cache: ^3
- yiisoft/yii2: ^2
Requires (Dev)
- dev-master
- 7.0.7
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.8
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.32
- 3.1.31
- 3.1.30
- 3.1.29
- 3.1.28
- 3.1.27
- 3.1.26
- 3.1.25
- 3.1.24
- 3.1.23
- 3.1.22
- 3.1.21
- 3.1.20
- 3.1.19
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-12-08 12:57:20 UTC
README
A library to bridge psr-16 simple caches with the yii caching system.
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar yii2-extended/yii2-psr16-simple-cache-bridge ^7
Basic Usage
This library offers one psr16 compliant simple cache to cache objects back to yii2 caching system. As the psr16 cache system do not have any dependancy mechanism, it will not use the one provided in yii's interfaces.
This library also offers one yii2 compliant cache to cache objects within any psr-16 cache. Be warned that the current implementation does not implements the dependancy mechanism yii's interfaces provides.
The Psr16ToYii2SimpleCache
is straightforward to use, just look at the
PSR-16 documentation.
use Yii2Extended\Yii2SimpleCache\Psr16ToYii2SimpleCache;
$cache = new Psr16ToYii2SimpleCache(\Yii::$app->get('cache'));
$cache->get('key');
$cache->set('key', $value);
The Yii2ToPsr16SimpleCache
is also simple to use but remember that
the dependancy mechanism is not implemented.
Put in the config/web.php
or config/console.php
:
'components' => [
'cache_bridge' => [
'class' => 'Yii2Extended\Yii2SimpleCache\Yii2ToPsr16SimpleCache',
'cache' => function() { return \Yii::$app->get('cache'); },
],
],
And then in your code :
use Yii2Extended\Yii2SimpleCache\Yii2ToPsr16SimpleCache;
$cache = \Yii::$app->get('cache_bridge');
$cache->get('key');
$cache->set('key', $value);
License
MIT (See license file).