RedisGears is a programmable serverless engine for transaction, batch, and event-driven data processing allowing users to write and run their own functions on data stored in Redis.
Functions can be implemented in different languages, including Python and C, and can be executed by the RedisGears engine in one of two ways:
Some batch type operations RedisGears can do:
person:
person:
to a setperson:
(assume all of them are of type hash)Some event type operations RedisGears can do:
I-AM-IMPORTANT:
and asynchronously dump them in a "deleted keys" log fileplayer:
and synchronously update a user's level when the score reaches 1000Run the Docker container:
For a very simple example that lists all keys in your Redis database with a prefix of person:
create the following python script and name it hello_gears.py
:
Execute your function:
The gears-cli tool provides an easier way to execute RedisGears functions, specially if you need to pass some parameters too.
It's written in Python and can be installed with pip
:
Usage:
docker run -p 6379:6379 redislabs/redisgears:latest
gb = GearsBuilder() gb.run('person:*')
docker exec -i redisgears redis-cli RG.PYEXECUTE "`cat hello_gears.py`"
pip install gears-cli
gears-cli hello_gears.py REQUIREMENTS rgsync
gears-cli --help
usage: gears-cli [-h] [--host HOST] [--port PORT]
[--requirements REQUIREMENTS] [--password PASSWORD] path [extra_args [extra_args ...]]