cache

cache is an instance of apicore.cache.Cache

class apicore.cache.Cache

Cache for the application. To use by importing the instance :

exemple:
from apicore import cache

key = "my_data"
date = {"color": "orange", "flag": True}
cache.set(key, data)
print(cache.get(key))

Note

If redis URI is configured the cache is store in redis server, otherwise it is cache in memory.

get(key)
Parameters:key (str) – the key referencing the data
set(key, value, expire=None)
Parameters:
  • key (str) – the key referencing the data
  • value – the data to store in cache
  • expire (integer) – Expire at a given timestamp in seconde.