PyPhi can optionally store the results of 𝚽 calculations as they’re computed in order to avoid expensive re-computation. These results can be stored locally on the filesystem (the default setting), or in a full-fledged database.
Caching is configured either in the
pyphi_config.yml file or at runtime by
pyphi.config. See the configuration documentation for more
Caching with MongoDb¶
Using the default caching system is easier and works out of the box, but using a database is more robust.
Once you have MongoDB installed, use
mongod to start the MongoDB server.
Make sure the
mongod configuration matches the PyPhi’s database
configuration settings in
pyphi_config.yml (see the configuration section of PyPhi’s
Caching with Redis¶
PyPhi can also use Redis as a fast in-memory global LRU cache to store Mice objects, reducing the memory load on PyPhi processes.
Install Redis. The redis.conf file provided with PyPhi includes the minimum settings needed to run Redis as an LRU cache:
Once the server is running you can enable Redis caching by setting
REDIS_CACHE: true in your
Note: PyPhi currently flushes the connected Redis database at the start of every execution. If you are running Redis for another application be sure PyPhi connects to its own Redis server.