You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cache_on_arguments not taking class member variables or class object into consideration #213
so it depends on how prevalent this pattern is, it might be most expedient to use region.get_or_create() directly instead if it's only in a few places. however if you want cache_on_arguments to take things for "self" into account you can use function_key_generator:
ClassA:
def__init__(self, param_1, param_2):
self.param_1=param_1self.param_2=param_2def_my_key_generator(namespace, fn, to_str=str):
# this is hardcoded to your fn below, however use inspect.getargspec(fn)# to build a cache key dynamicallydefgenerate_key(self, param):
returnf"{namespace}:{self.param_1}:{self.param_2}:{param}"returngenerate_key@region.cache_on_arguments(function_key_generator=_my_key_generator)defa(self, param):
returnparam*self.param_1*self.param_2
Activity
zzzeek commentedon Dec 22, 2021
so it depends on how prevalent this pattern is, it might be most expedient to use region.get_or_create() directly instead if it's only in a few places. however if you want cache_on_arguments to take things for "self" into account you can use function_key_generator: