Skip to content

模块 nonebot_plugin_marshoai.decos


func from_cache(key)

源代码在GitHub上查看
python
def from_cache(key):

    def decorator(func):

        def wrapper(*args, **kwargs):
            cached = cache.get(key)
            if cached:
                return cached
            else:
                result = func(*args, **kwargs)
                cache.set(key, result)
                return result
        return wrapper

文档完善中,欢迎提出建议或帮助我们完善。