super-simple/cache
最新稳定版本:v1.0.0
Composer 安装命令:
composer require super-simple/cache
包简介
The PHP cache library implementing psr-16.
README 文档
README
A simple cache library implementing PSR-16.
Install
composer require super-simple/cache
Requires PHP 8.4 or newer.
Usage
Basic usage:
<?php require_once __DIR__ . '/../vendor/autoload.php'; use SSCache\Cache; $cacheService = new Cache(new YourStorage()); // Adding a Serializer. // The CacheSerializeDelegator uses default php serializer. // For better performance could be added msgpack or igbinary. $cacheSerializer = new CacheSerializeDelegator($cache); // A CackeKeyDelegator must be the last one to handle key validation first $cache = new CacheKeyDlelegator($cacheSerializer); // Set the value $cache->set($key, $value, $ttl); // Get the value $result = $cache->get($key);
The $ttl could be int, null or \DateInterval
The storage must implement SSCache\CacheStorageInterface.
It's up to you how to handle $ttl in the storage.
If better performance is need it then install extensions (msgpack or igbinary) and implement serialize functions. A serializer must implement CacheSerializable or just extends the AbstractCacheSerializer.
Extra behavior could be added using a Delegator which extends AbstractCacheDelegator.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-10