大家好我现在正在模型类上使用@cached_property,并且喜欢在保存时删除它,以便在下次调用时可以重新填充它我该怎么做.例:
class Amodel():
#...model_fields....
@cached_property
def db_connection(self):
#get some thing in the db and cache here
instance = Amodel.objects.get(id=1)
variable = instance.db_connection
Amodel.objects.select_for_update().filter(id=1).update(#some variable)
#invalidate instance.db_connection
#new_variable = instance.db_connection
Run Code Online (Sandbox Code Playgroud)
谢谢