How to pass ignore arguments to the memoized cache in diskcache from local scope .
1.Since Cache is stored on disk , can it access the ignored arguments globally?
2.Is there a better way than writing wrappper function around the cached function?
Error:
Unresolved Reference for ignore={threshold_days, folder_path}
<code>import diskcache as dc
from datetime import datetime
cache = dc.Cache()
#LocalScope issue - Undefined 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
if __name__ == "__main__" :
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 )
</code>
<code>import diskcache as dc
from datetime import datetime
cache = dc.Cache()
#LocalScope issue - Undefined 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
if __name__ == "__main__" :
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 )
</code>
import diskcache as dc
from datetime import datetime
cache = dc.Cache()
#LocalScope issue - Undefined 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
if __name__ == "__main__" :
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 )
<code>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
</code>
<code>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
</code>
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
New contributor
Devansh Sojitra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1