ray/psr-cache-module
Composer 安装命令:
composer require ray/psr-cache-module
包简介
PSR-6 PSR-16 cache module for Ray.Di
README 文档
README
This package is the Ray.Di module that performs the PSR-6 / PSR-16 interface binding.
You can use the PSR6 cache interface in two ways: Local and Public.
Local is for caches that do not need to be shared among multiple web servers, and Public is for caches that need to be shared.
PHP8
use Psr\Cache\CacheItemPoolInterface; use Ray\PsrCacheModule\Annotation\Local; use Ray\PsrCacheModule\Annotation\Shared; class Foo { public function __construct( #[Local] private CacheItemPoolInterface $localPool, #[Shared] private CacheItemPoolInterface $sharedPool ){} }
PHP7.4
use Psr\Cache\CacheItemPoolInterface; use Ray\PsrCacheModule\Annotation\Local; use Ray\PsrCacheModule\Annotation\Shared; class Foo { private CacheItemPoolInterface $localPool; private CacheItemPoolInterface $sharedPool; /** * @Local('localPool') * @Shared('sharedPool') */ public function __construct( CacheItemPoolInterface $localPool, CacheItemPoolInterface $sharedPool ){ $this->localPool = $localPool; $this->sharedPool = $sharedPool; } }
Create object graph
use Ray\Di\AbstractModule; use Ray\Di\Injector; use Ray\PsrCacheModule\Psr6ArrayModule; $foo = (new Injector(new class extends AbstractModule { protected function configure() { $this->install(new Psr6ArrayModule()); // PSR-6 // $this->install(new Psr16CacheModule()); // PSR-16 } }))->getInstance(Foo::class); assert($foo instanceof Foo);
Installation
composer require ray/psr-cache-module
Module install
PSR-6
Psr6NullModule
This module is for the development.
- Local: Null
- Shared: Null
use Ray\PsrCacheModule\Psr6NullModule; new Psr6NullModule();
Psr6ArrayModule
This module is for the development.
- Local: Array
- Shared: Array
use Ray\PsrCacheModule\Psr6ArrayModule; new Psr6ArrayModule();
Psr6ApcuModule
This module is for a standalone server
- Local: Chain(APC, File)
- Shared: Chain(APC, File)
use Ray\PsrCacheModule\Psr6ApcuModule; new Psr6ApcuModule();
Psr6RedisModule
This module is for multiple servers.
- Local: Chain(APC, File)
- Shared: Redis
use Ray\PsrCacheModule\Psr6RedisModule; new Psr6RedisModule('redis1:6379:1'); // host:port:dbIndex
Psr6MemcachedModule
This module is for multiple servers.
- Local: Chain(APC, File)
- Shared: Memcached
use Ray\PsrCacheModule\Psr6MemcachedModule; new Psr6MemcachedModule('memcached1:11211:60,memcached2:11211:33'); // host:port:weight
See https://www.php.net/manual/en/memcached.addservers.php
PSR-16
If you install Psr16CacheModule, the cache engine installed with Psr6*Module can be used with PSR-16 interface. PSR-16 bindings use PSR-6 bindings.
use Ray\PsrCacheModule\Psr16CacheModule; new Psr16CacheModule();
Common Configuration Module
CacheDirModule
Specifies the cache directory. Optional.
use Ray\PsrCacheModule\CacheDirModule; new CacheDirModule('path/to/dir');
CacheNamespaceModule
Specifies the cache namespace (when multiple applications are placed on a single cache server). Optional.
use Ray\PsrCacheModule\CacheNamespaceModule; new CacheNamespaceModule('app1');
Technical Note
Redis, Memcached classes and symfony/cache adapters are not serializable, but RedisAdapter and MemcachedAdapter, which inherit from symfony/cache and are provided in this package, are.
ray/psr-cache-module 适用场景与选型建议
ray/psr-cache-module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 362.14k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ray/psr-cache-module 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ray/psr-cache-module 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 362.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 38
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-26