redis-om-python
redis-om-python copied to clipboard
Does this package support for redis cluster?
This package is helpful for the single-node Redis. But when I use it on the Redis cluster, I got the below error

So I wonder know this package supports Redis cluster version now?
Hello! I'm not sure that it will work, but I want to try something like this
class Test(JsonModel):
id: int
class Meta:
database = RedisCluster(startup_nodes=redis_conf, decode_responses=True)
There is indeed basic cluster support. However, some commands do fail
import datetime
from typing import Optional
from pydantic import EmailStr
from redis_om import (
Field,
HashModel,
JsonModel,
Migrator,
get_redis_connection
)
redis_conn = get_redis_connection(
url=f"redis://10.9.9.5:7002",
decode_responses=True,
password="D1ngD0ng"
)
class Customer(HashModel):
first_name: str
last_name: str = Field(index=True)
email: EmailStr
join_date: datetime.date
age: int = Field(index=True)
bio: Optional[str]
class Meta:
database = redis_conn
# First, we create a new `Customer` object:
andrew = Customer(
first_name="Andrew",
last_name="Brookins",
email="[email protected]",
join_date=datetime.date.today(),
age=38,
bio="Python developers, works at Redis, Inc."
)
# The model generates a globally unique primary key automatically without needing to talk to Redis.
print(andrew.pk)
> "01FJM6PH661HCNNRC884H6K30C"
# We can save the model to Redis by calling `save()`:
Migrator().run()
andrew.save()
# Expire the model after 2 mins (120 seconds)
andrew.expire(120)
# To retrieve this customer with its primary key, we use `Customer.get()`:
assert Customer.get(andrew.pk) == andrew
print(Customer.get(andrew.pk))
print(Customer.find(Customer.age == 38).all()) # This line fails
Mentioning #412 here to track.