phapi / cache-redis
此包已被废弃,不再维护。未建议替代包。
使用 Redis 作为后端的缓存提供者
1.0.0
2015-07-09 15:23 UTC
Requires
- php: >=5.5.0
- phapi/contract: 1.*
- phapi/exception: 1.*
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mockery/mockery: 0.9.*
- phpunit/phpunit: 4.6.*
This package is not auto-updated.
Last update: 2021-02-05 22:01:10 UTC
README
此缓存提供者使用 Redis 作为后端存储缓存项。
Phapi 关于缓存有一条重要规则:正常工作的缓存不应是应用程序运行的必要条件。因此,如果 Phapi 无法连接到缓存后端,它不会停止执行。相反,配置的缓存将被一个虚拟缓存 new NullCache()
替换。
安装
Phapi 框架默认不安装此包。将包作为 composer 的依赖项添加以安装包。
$ composer require phapi/cache-redis:1.*
配置
配置包并将其添加到容器中以启用它。
<?php $container['cache'] = function ($container) { return new \Phapi\Cache\Redis\Redis($servers = [ [ 'host' => 'localhost', 'port' => 6379, ] ]); };
当前 Redis 缓存提供者不支持集群。
有关如何配置与 Phapi 框架的集成的更多信息,请参阅配置文档。
通用缓存使用
<?php // Add something to the cache $cache->set('test', 'value'); // Read something from the cache echo $cache->get('test'); // Will echo "value" // Check if something exists in the cache $bool = $cache->has('test'); // Remove from cache $cache->clear('test'); // Flush the cache $cache->flush();
许可证
Redis 缓存提供者采用 MIT 许可证 - 有关详细信息,请参阅license.md 文件。
贡献
贡献、错误修复等始终欢迎。请点击此处。