def invalidate_obj(obj): """ Invalidates caches that can possibly be influenced by object """ model = non_proxy(obj.__class__) load_script('invalidate')(args=[ get_model_name(model), serialize_object(model, obj) ])
def cache_thing(model, cache_key, data, cond_dnf=[[]], timeout=None): """ Writes data to cache and creates appropriate invalidators. """ model = non_proxy(model) if timeout is None: profile = model_profile(model) timeout = profile['timeout'] pickled_data = pickle.dumps(data, -1) load_script('cache_thing')( keys=[cache_key], args=[ pickled_data, get_model_name(model), json.dumps(cond_dnf, default=str), timeout, # Invalidator timeout should be larger than timeout of any key it references # So we take timeout from profile which is our upper limit # Add few extra seconds to be extra safe model._cacheprofile['timeout'] + 10 ] )