Ignoring function arguments with ttl_cache
Closed this issue · 2 comments
floatingpurr commented
Hi folks! I need to ignore some params of a function decorated with @ttl_cache
E.g.:
@ttl_cache(maxsize=1024, ttl=600)
def my_func(foo, ignore_bar, ignore_baz):
# do stuff
Working that way, I get this:
>>> my_func("foo", "ignore_bar", "ignore_baz") # cache miss
>>> my_func("foo", "ignore_bar", "ignore_baz") # cache hit
>>> my_func("foo", "ignore_bar_bar", "ignore_baz_baz") # cache miss!
What I need:
>>> my_func("foo", "ignore_bar", "ignore_baz") # cache miss
>>> my_func("foo", "ignore_bar", "ignore_baz") # cache hit
>>> my_func("foo", "ignore_bar_bar", "ignore_baz_baz") # cache hit!!!!!
It looks like there isn't any straightforward way to do that (see this thread in SO), but I might be wrong
tkem commented
Please see the answer on SO, posting generic questions there and reserving GitHub Issues for bug reports is encouraged ;-)
floatingpurr commented