Installation

Python Version

We recommend using the latest version of Python. CacheLib supports Python 3.8 and newer.

Dependencies

There are no required dependencies beyond Python itself. CacheLib is a standalone library that works out of the box.

Optional Dependencies

When you install CacheLib SimpleCache and FileSystemCache will work without any additional dependencies. However, some backends require additional dependencies to be installed.

CacheLib will detect and use them if they are already installed but you will need to install them manually if you want to use the corresponding backends:

Install redis-py required for RedisCache.

Virtual Environments

Use a virtual environment to manage the dependencies for your project, both in development and in production.

What problem does a virtual environment solve? The more Python projects you have, the more likely it is that you need to work with different versions of Python libraries, or even Python itself. Newer versions of libraries for one project can break compatibility in another project.

Virtual environments are independent groups of Python libraries, one for each project. Packages installed for one project will not affect other projects or the operating system’s packages.

Python comes bundled with the venv module to create virtual environments.

Create an environment

Create a project folder and a .venv folder within:

$ mkdir myproject
$ cd myproject
$ python3 -m venv .venv

Activate the environment

Before you work on your project, activate the corresponding environment:

$ . .venv/bin/activate

Your shell prompt will change to show the name of the activated environment.

Install CacheLib

Within the activated environment, use the following command to install CacheLib:

$ pip install cachelib

CacheLib is now installed. Check out the Quickstart to get started.