Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing ignore arguments to memoized cache from local scope (diskcache python) #324

Open
starzar opened this issue Jul 18, 2024 · 0 comments

Comments

@starzar
Copy link

starzar commented Jul 18, 2024

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}

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant