Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(0)  |  Call(0)  |  Derive(0)  |  Import(0)

src/d/j/dj-cache-tools-0.5.0/cache_tools/utils.py   dj-cache-tools(Download)
def invalidate_cache_for_object(obj):
    key = _get_key(conf.KEY_PREFIX, ContentType.objects.get_for_model(obj), pk=obj.pk, version_key=True)
    try:
        cache.incr(key)
    except ValueError:
        model_ct = model
 
    key = _get_key(conf.KEY_PREFIX, model_ct, **kwargs)
 
    obj = cache.get(key)
            cache.set(key, obj, timeout)
        elif not isinstance(cache, DummyCache):
            cache.set_many({key: obj, _get_key(conf.KEY_PREFIX, model_ct, pk=obj.pk): obj}, timeout=timeout)
 
    return obj
        pks = [(ContentType.objects.get_for_id(ct_id), pk) for (ct_id, pk) in pks]
 
    keys = [_get_key(conf.KEY_PREFIX, model, pk=pk) for (model, pk) in pks]
 
    cached = cache.get_many(keys)