Caching
By default, AI JSON caches all action outputs with a shelve file in a temporary directory.
Controlling caching
To disable caching, set the cache
variable to False
in your action:
Alternatively, to disable caching for a specific run of the action, subclass CacheControlOutputs
on the output object:
For more information see Output Modifiers.
Providers
On disk
The default AI JSON behavior is to create a temporary file for storing cache entries.
Every flow will use a new temporary directory.
To share the directory among flows, or to persist it across runs, explicitly instantiate the ShelveCacheRepo
, and pass it to the Flow
constructor:
With Redis
We also support Redis as a cache backend:
Run Redis locally or use a cloud provider.
Set the following environment variables:
REDIS_HOST
(required)REDIS_PASSWORD
(required)REDIS_PORT
(optional, defaults to 6379)REDIS_USERNAME
(optional, defaults to empty string)
- Override the default cache with: