add LightCache support

This commit is contained in:
crazywhalecc
2022-12-31 15:27:09 +08:00
parent 3734f5d476
commit fd8b3721ae
7 changed files with 288 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ use ZM\Middleware\MiddlewareHandler;
use ZM\Store\Database\DBException;
use ZM\Store\Database\DBQueryBuilder;
use ZM\Store\Database\DBWrapper;
use ZM\Store\KV\KVInterface;
use ZM\Utils\ZMRequest;
// 防止重复引用引发报错
if (function_exists('zm_internal_errcode')) {
@@ -246,3 +248,12 @@ function bot(): ZM\Context\BotContext
}
return new \ZM\Context\BotContext('', '');
}
function kv(string $name = ''): KVInterface
{
global $kv_class;
if (!$kv_class) {
$kv_class = config('global.kv.use', \LightCache::class);
}
return $kv_class::open($name);
}