Login

Tag "get_cache_or_object"

Snippet List

get_cache_or_query - Shortcut to common cache signature

Replaces something like this: cache_key = 'game1' the_game = cache.get(cache_key) if not the_game: the_game = Game.objects.get(id=1) cache.set(cache_key, the_game, 60*24*5) With this: the_game = get_cache_or_query('game1', Game, seconds_to_cache=60*24*5, id=1)

  • cache
  • optimization
  • get_cache_or_object
Read More

1 snippet posted so far.