Skip to content

Provided RedisDataStore does not work since redis.get() returns bytes rather than strings #32

@gibsondan

Description

@gibsondan

The reference RedisDataStore here appears to be broken:

class RedisDataStore(IDataStore):
_connection: redis.Redis
def __init__(self, host: str, port: int, password: str):
if not has_imported_redis:
raise ImportError("Failed to import redis, have you installed the redis dependency?")
self._connection = redis.Redis(host=host, port=port, password=password)
def get(self, key: str) -> str | None:
return self._connection.get(key)
def set(self, key: str, value: str):
self._connection.set(key, value)
def shutdown(self):
self._connection.shutdown()

Redis.get returns bytes, not a string. Setting decode_responses to True when constructing the client appears to be one way to resolve the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions