Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this package support for redis cluster? #174

Open
TsaiZX opened this issue Mar 30, 2022 · 3 comments
Open

Does this package support for redis cluster? #174

TsaiZX opened this issue Mar 30, 2022 · 3 comments
Assignees

Comments

@TsaiZX
Copy link

TsaiZX commented Mar 30, 2022

This package is helpful for the single-node Redis.
But when I use it on the Redis cluster, I got the below error

Screenshot from 2022-03-30 15-56-29

So I wonder know this package supports Redis cluster version now?

@TsaiZX TsaiZX changed the title Does this tool support for redis cluster? Does this package support for redis cluster? Mar 30, 2022
@DennyD17
Copy link

DennyD17 commented May 12, 2022

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)

@XChikuX
Copy link

XChikuX commented Nov 4, 2022

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

@XChikuX
Copy link

XChikuX commented Jan 17, 2023

Mentioning #412 here to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants