恢复上次

This commit is contained in:
ManyManyTomato 2025-07-05 13:02:07 +00:00
parent 894ac06041
commit b2210538b3

View File

@ -1,15 +1,14 @@
import inspect
from collections.abc import Callable
from datetime import datetime
from functools import wraps
import inspect
from typing import Any, ClassVar, Generic, TypeVar
import nonebot
from aiocache import Cache as AioCache
# from aiocache.backends.redis import RedisCache
from aiocache.base import BaseCache
from aiocache.serializers import JsonSerializer
import nonebot
from nonebot.compat import model_dump
from nonebot.utils import is_coroutine_callable
from pydantic import BaseModel, PrivateAttr
@ -577,24 +576,21 @@ class CacheManager:
expire: 过期时间
"""
def new(self, name: str, lazy_load: bool = True, expire: int = 600):
def wrapper(func: Callable):
_name = name.upper()
if _name in self._data:
raise DbCacheException(f"缓存 {name} 已存在")
def wrapper(func: Callable):
_name = name.upper()
if _name in self._data:
raise DbCacheException(f"缓存 {name} 已存在")
self._data[_name] = CacheData(
name=_name,
func=func,
expire=expire,
lazy_load=lazy_load,
_cache=self._cache,
)
return func
cache_data = CacheData(
name=_name,
func=func,
expire=expire,
lazy_load=lazy_load,
)
cache_data._cache = self._cache
self._data[_name] = cache_data
return func
return wrapper
return wrapper
def listener(self, name: str):
"""创建缓存监听器"""