首页 > 解决方案 > 如何调用缓存清除类方法?

问题描述

我有这个代码:

class Test(CqlEngineModel):
     @classmethod
     @cql_engine_connector
     @functools.lru_cache(maxsize=1000)
     def is_not_analyzable(cls, x, y):
        if mic:
           query_result = ...
           mic_list = cls._to_list(query_result)   
           return True if mic_list else False
        else:
           return False

在外面我需要调用 cache_clear 函数,如下所示:

Test.is_not_analyzable.cache_clear()

但我有这个错误:

AttributeError: 'function' object has no attribute 'cache_clear

标签: pythonpython-3.xcachingclass-method

解决方案


推荐阅读