ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
### 扩展 * * * * * 1. 在library/msqphp/framework/core/cache/handlers/下创建自定义cache处理类 1. 命名空间为msqphp\core\cache\handlers.(不需要在composer下注册) 1. 继承msqphp\core\cache\CacheHandlerInterface 1. 构造函数接受一个配置数组,参数在cache配置中配置 1. 按照cache类正常使用方法使用 1. 最好支持队列 ~~~ //例 <?php declare(strict_types = 1); namespace msqphp\core\cache\handlers; Interface CacheHandlerInterface { //构造函数 public function __construct(array $config); /** * @param array $config 缓存驱动配置 * @param string $key 缓存键 * @param string $val 缓存值 * @param int $expire 缓存有效期 * @param int $offset 偏移量 * @throws CacheHandlerException * @return bool 是否存在 * @return void 如果出错抛出异常, 返回什么false */ // 是否可用 public function available(string $key) : bool; // 得到缓存信息 public function get(string $key); // 递增 public function increment(string $key, int $offset) : int; // 递减 public function decrement(string $key, int $offset) : int; // 设置缓存 public function set(string $key, $value, int $expire) : void; // 清除缓存 public function delete(string $key) : void; // 清空 public function clear() : void; } ~~~