ttldict

TTL dictionary

Tricks / features:
  • calling len() will remove expired keys
  • __repr__() might show expired values, doesn’t remove expired ones
class tangogql.ttldict.TTLDict(default_ttl, *args, **kwargs)[source]

Dictionary with TTL Extra args and kwargs are passed to initial .update() call

expire_at(key, timestamp)[source]

Set the key expire timestamp

get_ttl(key, now=None)[source]

Return remaining TTL for a key

is_expired(key, now=None, remove=False)[source]

Check if key has expired

set_ttl(key, ttl, now=None)[source]

Set TTL for the given key