Cache

PostgreSQL

Redis

Memory

API

Implementing a custom cache backend consists on implementing the following interface:

class cliquet.cache.CacheBase(*args, **kwargs)
initialize_schema()

Create every necessary objects (like tables or indices) in the backend.

This is excuted when the cliquet migrate command is ran.

flush()

Delete every values.

ttl(key)

Obtain the expiration value of the specified key.

Parameters:key (str) – key
Returns:number of seconds or negative if no TTL.
Return type:float
expire(key, ttl)

Set the expiration value ttl for the specified key.

Parameters:
  • key (str) – key
  • ttl (float) – number of seconds
set(key, value, ttl=None)

Store a value with the specified key. If ttl is provided, set an expiration value.

Parameters:
  • key (str) – key
  • value (str) – value to store
  • ttl (float) – expire after number of seconds
get(key)

Obtain the value of the specified key.

Parameters:key (str) – key
Returns:the stored value or None if missing.
Return type:str
delete(key)

Delete the value of the specified key.

Parameters:key (str) – key