将忽略参数传递给记忆缓存(diskcache python)

问题描述 投票:0回答:1

如何将忽略参数传递给磁盘缓存中的记忆缓存?
未解决的忽略参考= {threshold_days,folder_path}

import diskcache as dc
from datetime import datetime

cache = dc.Cache()
#Unresolved Reference  ignore={threshold_days, folder_path}
@dc.Cache().memoize(tag='runoncetoday', ignore={threshold_days, folder_path})
def delete_olddata_func(day_today):
###     run file deleteion function only once at the start of the day and skip it when called again on the same day .
    pass

day_today  = datetime.now().date()
threshold_days= 25
folder_path = "/myDir"
delete_olddata_func(day_today=day_today, threshold_days=threshold_days, folder_path = folder_path )
python-3.x diskcache
1个回答
0
投票
from diskcache import Cache
cache = Cache('/path/to/cache')
@cache.memoize(ttl=60, ignore=['threshold_days', 'folder_path'])
def my_function(threshold_days, folder_path, other_arg):

#function implementation

pass
© www.soinside.com 2019 - 2024. All rights reserved.