A dirt-simple postgresql-based cache system
Added tag 0.1.0 for changeset ffa6ae709057
full namespace support
do not forget to update idate on update

heads

default
browse log
0.1.0
browse .tar.gz

clone

read-only
https://hg.sr.ht/~pythonian/dbcache
read/write
ssh://hg@hg.sr.ht/~pythonian/dbcache

DBCACHE

This small library allows to cache costly things within a postgresql table.

keys and values are bytes.

Example usage:

from time import sleep
  from datetime import timedelta
  from dbcache.api import dbcache

  cache = dbcache('postgresql://foo:bar@postgresql/mydb')

  assert cache.get(b'a') is None
  cache.set(b'a', b'aaa')
  assert cache.get(b'a') == b'aaa'

  cache.set(b'b', b'bbb', lifetime=timedelta(seconds=1))
  assert cache.get(b'b') == b'bbb'
  sleep(1)
  assert cache.get(b'b') is None