Skip to content

Latest commit

 

History

History
148 lines (93 loc) · 3.92 KB

redismodules.rst

File metadata and controls

148 lines (93 loc) · 3.92 KB

Redis Modules Commands

Accessing redis module commands requires the installation of the supported Redis module. For a quick start with redis modules, try the Redismod docker.

RedisBloom Commands

These are the commands for interacting with the RedisBloom module. Below is a brief example, as well as documentation on the commands themselves.

Create and add to a bloom filter

import redis
r = redis.Redis()
r.bf().create("bloom", 0.01, 1000)
r.bf().add("bloom", "foo")

Create and add to a cuckoo filter

import redis
r = redis.Redis()
r.cf().create("cuckoo", 1000)
r.cf().add("cuckoo", "filter")

Create Count-Min Sketch and get information

import redis
r = redis.Redis()
r.cms().initbydim("dim", 1000, 5)
r.cms().incrby("dim", ["foo"], [5])
r.cms().info("dim")

Create a topk list, and access the results

import redis
r = redis.Redis()
r.topk().reserve("mytopk", 3, 50, 4, 0.9)
r.topk().info("mytopk)

redis.commands.bf.commands


RedisGraph Commands

These are the commands for interacting with the RedisGraph module. Below is a brief example, as well as documentation on the commands themselves.

Create a graph, adding two nodes

import redis
from redis.graph.node import Node

john = Node(label="person", properties={"name": "John Doe", "age": 33}
jane = Node(label="person", properties={"name": "Jane Doe", "age": 34}

r = redis.Redis()
graph = r.graph()
graph.add_node(john)
graph.add_node(jane)
graph.add_node(pat)
graph.commit()

redis.commands.graph.node

redis.commands.graph.edge

redis.commands.graph.commands


RedisJSON Commands

These are the commands for interacting with the RedisJSON module. Below is a brief example, as well as documentation on the commands themselves.

Create a json object

import redis
r = redis.Redis()
r.json().set("mykey", ".", {"hello": "world", "i am": ["a", "json", "object!"]})

Examples of how to combine search and json can be found here.

redis.commands.json.commands


RediSearch Commands

These are the commands for interacting with the RediSearch module. Below is a brief example, as well as documentation on the commands themselves. In the example below, an index named my_index is being created. When an index name is not specified, an index named idx is created.

Create a search index, and display its information

import redis
from redis.commands.search.field import TextField

r = redis.Redis()
index_name = "my_index"
r.ft(index_name).create_index(TextField("play", weight=5.0), TextField("ball"))
print(r.ft(index_name).info())

redis.commands.search.commands


RedisTimeSeries Commands

These are the commands for interacting with the RedisTimeSeries module. Below is a brief example, as well as documentation on the commands themselves.

Create a timeseries object with 5 second retention

import redis
r = redis.Redis()
r.ts().create(2, retension_msecs=5000)

redis.commands.timeseries.commands