yii2-extended / yii2-psr16-simple-cache-bridge
一个用于连接psr-16简单缓存与yii缓存系统的库
7.0.6
2024-07-31 13:27 UTC
Requires
- php: >=8.0
- psr/simple-cache: ^3
- yiisoft/yii2: ^2
Requires (Dev)
- dev-master
- 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-08-31 11:40:36 UTC
README
一个用于连接psr-16简单缓存与yii缓存系统的库。
安装
此库的安装通过composer进行,所有类的自动加载都通过它们的自动加载器完成。
- 从他们的网站下载
composer.phar
。 - 然后运行以下命令将此库作为依赖项安装
php composer.phar yii2-extended/yii2-psr16-simple-cache-bridge ^7
基本用法
此库提供了一个psr16兼容的简单缓存,用于将对象缓存回yii2缓存系统。由于psr16缓存系统没有依赖机制,它不会使用yii接口中提供的那个。
此库还提供了一个yii2兼容的缓存,用于在psr-16缓存中缓存对象。请注意,当前实现没有实现yii接口提供的依赖机制。
Psr16ToYii2SimpleCache
的使用非常简单,只需查看 PSR-16 文档。
use Yii2Extended\Yii2SimpleCache\Psr16ToYii2SimpleCache;
$cache = new Psr16ToYii2SimpleCache(\Yii::$app->get('cache'));
$cache->get('key');
$cache->set('key', $value);
Yii2ToPsr16SimpleCache
的使用也很简单,但请记住依赖机制尚未实现。
在 config/web.php
或 config/console.php
中添加
'components' => [
'cache_bridge' => [
'class' => 'Yii2Extended\Yii2SimpleCache\Yii2ToPsr16SimpleCache',
'cache' => function() { return \Yii::$app->get('cache'); },
],
],
然后在您的代码中
use Yii2Extended\Yii2SimpleCache\Yii2ToPsr16SimpleCache;
$cache = \Yii::$app->get('cache_bridge');
$cache->get('key');
$cache->set('key', $value);
许可
MIT (查看 许可文件)。