dadapas/cache
Composer 安装命令:
composer require dadapas/cache
包简介
PSR-6 and PSR-16 Implementations
README 文档
README
PHP Cache
This is an implementation of PSR-6 and PSR-16 cache interface,
Installation
Install composer if not and enter the command
composer require dadapas/cache
Basic usage
A basic usage of cache
use Dadapas\Cache\CacheItemPool; use Dadapas\Cache\CacheItem; use Dadapas\Cache\FileCacheAdapter; // Declarations $adapter = new FileCacheAdapter(__DIR__."/cache"); // cache adapter $pool = new CacheItemPool($adapter); // pool $key = "mykey"; $cacheItem = new CacheItem($key); // cache item // Set the cache value $cacheItem->set("cache value"); $cacheItem->expiresAfter(3600); // cache will live in 1 hour $pool->save($cache); // Save the cache // ...
To get a cache from the pool
// Get cache by key null if key not exist $cacheItem = $pool->getItem($key); // get the cache value null if expires or non exist key $cacheItem->get(); // To get the key $cacheItem->getKey(); // Set the exact expiration date // This data will expire in 1st january 2023 $cacheItem->expiresAt(new DateTime("2023-01-01")); //
You can then pick one of the implementations of the interface to get a logger.
If you want to implement the interface, you can require this package and
implement Psr\Cache\CacheItemPoolInterface in the code code. Please read the
specification text
for details.
Test
For making a test just
composer test
License
The licence is MIT for more details click here
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-09