You can use different caches according to your needs. All the caches implement the same interface.

Caches are always working together with a serializer which transforms data when storing and retrieving from the backend. It may also contain plugins that are able to enrich the behavior of your cache (like adding metrics, logs, etc).

This is the flow of the set command:


Let’s go with a more specific case. Let’s pick Redis as the cache with namespace “test” and PickleSerializer as the serializer:

  1. We receive set("key", "value").
  2. Hook pre_set of all attached plugins (none by default) is called.
  3. “key” will become “test:key” when calling build_key.
  4. “value” will become an array of bytes when calling serializer.dumps because of PickleSerializer.
  5. the byte array is stored together with the key using set cmd in Redis.
  6. Hook post_set of all attached plugins is called.

By default, all commands are covered by a timeout that will trigger an asyncio.TimeoutError in case of timeout. Timeout can be set at instance level or when calling the command.

The supported commands are:

  • add
  • get
  • set
  • multi_get
  • multi_set
  • delete
  • exists
  • increment
  • expire
  • clear
  • raw

If you feel a command is missing here do not hesitate to open an issue