The beta release of GLIDE for Redis was tested on Intel x86_64 using Ubuntu 22.04.1, Amazon Linux 2023 (AL2023), and macOS 12.7.
Python 3.8 or higher.
To install GLIDE for Redis using pip
, follow these steps:
- Open your terminal.
- Execute the command below:
$ pip install glide-for-redis
- After installation, confirm the client is accessible by running:
$ python3 >>> import glide
Software Dependencies
- python3 virtualenv
- git
- GCC
- pkg-config
- protoc (protobuf compiler)
- openssl
- openssl-dev
- rustup
Dependencies installation for Ubuntu
sudo apt update -y
sudo apt install -y python3 python3-venv git gcc pkg-config protobuf-compiler openssl libssl-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Dependencies installation for CentOS
sudo yum update -y
sudo yum install -y python3 git gcc pkgconfig protobuf-compiler openssl openssl-devel
pip3 install virtualenv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Dependencies installation for MacOS
brew update
brew install python3 git gcc pkgconfig protobuf openssl
pip3 install virtualenv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Before starting this step, make sure you've installed all software requirments.
- Clone the repository:
VERSION=0.1.0 # You can modify this to other released version or set it to "main" to get the unstable branch git clone --branch ${VERSION} https://github.com/aws/glide-for-redis.git cd glide-for-redis
- Initialize git submodule:
git submodule update --init --recursive
- Generate protobuf files:
GLIDE_ROOT_FOLDER_PATH=. protoc -Iprotobuf=${GLIDE_ROOT_FOLDER_PATH}/glide-core/src/protobuf/ --python_out=${GLIDE_ROOT_FOLDER_PATH}/python/python/glide ${GLIDE_ROOT_FOLDER_PATH}/glide-core/src/protobuf/*.proto
- Create a virtual environment:
cd python python3 -m venv .env
- Activate the virtual environment:
source .env/bin/activate
- Install requirements:
pip install -r requirements.txt
- Build the Python wrapper in release mode:
maturin develop --release --strip
Note: To build the wrapper binary with debug symbols remove the --strip flag.
- Run tests:
- Ensure that you have installed redis-server and redis-cli on your host. You can find the Redis installation guide at the following link: Redis Installation Guide.
- Validate the activation of the virtual environment from step 4 by ensuring its name (
.env
) is displayed next to your command prompt. - Execute the following command from the python folder:
pytest --asyncio-mode=auto
Note: To run redis modules tests, add -k "test_redis_modules.py".
>>> from glide import (
... NodeAddress,
... ClusterClientConfiguration,
... RedisClusterClient,
... )
>>> addresses = [NodeAddress("redis.example.com", 6379)]
>>> config = ClusterClientConfiguration(
... addresses=addresses
... )
>>> client = await RedisClusterClient.create(config)
>>> await client.set("foo", "bar")
'OK'
>>> await client.get("foo")
'bar'
>>> from glide import (
... NodeAddress,
... RedisClientConfiguration,
... RedisClient,
... )
>>> addresses = [NodeAddress("redis_primary.example.com", 6379), NodeAddress("redis_replica.example.com", 6379)]
>>> config = RedisClientConfiguration(
... addresses=addresses
... )
>>> client = await RedisClient.create(config)
>>> await client.set("foo", "bar")
'OK'
>>> await client.get("foo")
'bar'