Skip to content

Instantly share code, notes, and snippets.

@fernandoflorez
Created March 19, 2013 20:06
Show Gist options
  • Save fernandoflorez/5199604 to your computer and use it in GitHub Desktop.
Save fernandoflorez/5199604 to your computer and use it in GitHub Desktop.
jinja2 RedisBytecodeCache
class RedisBytecodeCache(BytecodeCache):
def __init__(self, conn):
self._conn = conn
def load_bytecode(self, bucket):
code = self._conn.get(bucket.key)
if code is not None:
return bucket.bytecode_from_string(code)
def dump_bytecode(self, bucket):
self._conn.set(bucket.key, bucket.bytecode_to_string())
def clear(self):
self._conn.delete(*self._conn.keys())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment