mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 00:55:35 +08:00
let KVInterface extends CacheInterface
This commit is contained in:
@@ -7,6 +7,7 @@ use OneBot\Driver\Coroutine\CoroutineInterface;
|
|||||||
use OneBot\Driver\Process\ExecutionResult;
|
use OneBot\Driver\Process\ExecutionResult;
|
||||||
use OneBot\V12\Object\MessageSegment;
|
use OneBot\V12\Object\MessageSegment;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Psr\SimpleCache\CacheInterface;
|
||||||
use ZM\Config\ZMConfig;
|
use ZM\Config\ZMConfig;
|
||||||
use ZM\Container\ContainerHolder;
|
use ZM\Container\ContainerHolder;
|
||||||
use ZM\Logger\ConsoleLogger;
|
use ZM\Logger\ConsoleLogger;
|
||||||
@@ -259,6 +260,12 @@ function bot(): ZM\Context\BotContext
|
|||||||
return new \ZM\Context\BotContext('', '');
|
return new \ZM\Context\BotContext('', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个 KV 库实例
|
||||||
|
*
|
||||||
|
* @param string $name KV 库名称
|
||||||
|
* @return CacheInterface
|
||||||
|
*/
|
||||||
function kv(string $name = ''): Psr\SimpleCache\CacheInterface
|
function kv(string $name = ''): Psr\SimpleCache\CacheInterface
|
||||||
{
|
{
|
||||||
global $kv_class;
|
global $kv_class;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace ZM\Store\KV;
|
|||||||
|
|
||||||
use Psr\SimpleCache\CacheInterface;
|
use Psr\SimpleCache\CacheInterface;
|
||||||
|
|
||||||
interface KVInterface
|
interface KVInterface extends CacheInterface
|
||||||
{
|
{
|
||||||
public static function open(string $name = ''): CacheInterface;
|
public static function open(string $name = ''): CacheInterface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use ZM\Store\FileSystem;
|
|||||||
/**
|
/**
|
||||||
* 轻量、基于本地 JSON 文件的 KV 键值对缓存
|
* 轻量、基于本地 JSON 文件的 KV 键值对缓存
|
||||||
*/
|
*/
|
||||||
class LightCache implements CacheInterface, KVInterface
|
class LightCache implements KVInterface
|
||||||
{
|
{
|
||||||
/** @var array 存放库对象的列表 */
|
/** @var array 存放库对象的列表 */
|
||||||
private static array $objs = [];
|
private static array $objs = [];
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace ZM\Store\KV\Redis;
|
|||||||
use Psr\SimpleCache\CacheInterface;
|
use Psr\SimpleCache\CacheInterface;
|
||||||
use ZM\Store\KV\KVInterface;
|
use ZM\Store\KV\KVInterface;
|
||||||
|
|
||||||
class KVRedis implements CacheInterface, KVInterface
|
class KVRedis implements KVInterface
|
||||||
{
|
{
|
||||||
private string $pool_name;
|
private string $pool_name;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user