Dinidiniz
Dinidiniz

Reputation: 811

Delete all related to variable in function using delete_memoized of Flask-Caching

I have some functions like the one below:

@cache.memoize(timeout=18000)
def getAllHave(user_id, i,
          currency = "USD")

Parameters currency and i can have a huge amount of values.

I would like to delete all cache from function getAllHave related to a specific user_id.

Possibilities I thought:

1. cache.delete_memoized(getAllHave)
2. cache.delete_memoized(getAllHave, user_id)
3. cache.delete_memoized(getAllHave, user_id, 2, "USD")

The first one actually works, but it deletes all cache related to the function, not only the ones I want.

The second one doesn't work.

The third one works, but it is just too narrow, and I can't do a loop to delete all.

What I am doing wrong? Or this kind of feature just not available?

Upvotes: 2

Views: 252

Answers (0)

Related Questions