yii2-extended/yii2-psr6-cache-bridge 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yii2-extended/yii2-psr6-cache-bridge

最新稳定版本:8.0.10

Composer 安装命令:

composer require yii2-extended/yii2-psr6-cache-bridge

包简介

A library to bridge psr-6 caches with the yii caching system.

README 文档

README

A library to bridge psr-6 caches with the yii caching system.

coverage build status

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-psr6-cache-bridge ^8

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 Psr6ToYii2Cache is straightforward to use, just look at the PSR-16 documentation.


use Yii2Extended\Yii2Cache\Psr6ToYii2Cache;

$cache = new Psr6ToYii2Cache(\Yii::$app->get('cache'));
$cache->get('key');
$cache->set('key', $value);

The Yii2ToPsr6Cache 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\Yii2Cache\Yii2ToPsr6Cache',
			'cache' => function() { return \Yii::$app->get('cache'); },
		],
	],

And then in your code :


use Yii2Extended\Yii2Cache\Yii2ToPsr6Cache;

$cache = \Yii::$app->get('cache_bridge');
$item = $cache->getItem('key');
$item->expiresAt($datetime);
$item->setValue($value);
$cache->setItem($item);

License

MIT (See license file).

统计信息

  • 总下载量: 24.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-16