parshikovpavel / psr-cache-adapter
将PSR-6对象池实现转换为PSR-16简单缓存接口的适配器装饰器
0.0.2
2019-10-08 14:41 UTC
Requires
- php: ^7.1
- psr/cache: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-09 01:48:54 UTC
README
该软件包包含一个适配器,用于装饰一个PSR-6对象池实现并将其转换为PSR-16简单缓存接口。
适配器可以在开发PSR-6和PSR-16兼容的缓存库时避免代码重复。只需要开发一个PSR-6实现,然后使用此适配器进行适配。
适配器与一个软件包进行了测试,用于使用PHP数组在内存中缓存数据。
安装
建议使用Composer进行安装。
从项目根目录运行以下命令
composer require parshikovpavel/psr-cache-adapter
用法
有关库中实现接口的详细描述,请参阅PSR-6和PSR-16。
只需将创建的PSR-6对象池类注入到适配器构造函数中,如下所示
use ppCache\Psr6ToPsr16Adapter; /* Creating an instance of some PSR-6 pool */ /** @var \Psr\Cache\CacheItemPoolInterface $psr6 */ $psr6 = new SomeCacheItemPool(); /* Adapting it to the PSR-16 simple cache interface */ $psr16 = new Psr6ToPsr16Adapter($psr6);