redis_tools.config
Exposes the configuration for connecting to a redis database.
- class redis_tools.config.RedisConfig(*, host: str = 'localhost', port: int = 6379, db: int = 0, password: str | None = None, ssl: bool = False, encoding: str | None = 'utf-8')[source]
Bases:
BaseModel
Configuration for connecting to redis database.
Inorder to connect to a redis database, there are a number of configurations that are needed including the server’s host address and port. RedisConfig computes a redis-url similar to redis://:password@host:self.port/db
- host
the host address where the redis server is found (default: ‘localhost’).
- Type:
str
- port
the port on which the redis server is running (default: 6379).
- Type:
int
- db
the redis database identifier (default: 0).
- Type:
int
- password
the password for connecting to the redis server (default: None).
- Type:
Optional[int]
- ssl
whether the connection to the redis server is to be via TLS (default: False)
- Type:
bool
- encoding
(Optional[str]): the string encoding used with the redis database (default: utf-8)
- Type:
str | None
- db: int
- encoding: str | None
- host: str
- model_config: ClassVar[ConfigDict] = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'db': FieldInfo(annotation=int, required=False, default=0), 'encoding': FieldInfo(annotation=Union[str, NoneType], required=False, default='utf-8'), 'host': FieldInfo(annotation=str, required=False, default='localhost'), 'password': FieldInfo(annotation=Union[str, NoneType], required=False), 'port': FieldInfo(annotation=int, required=False, default=6379), 'ssl': FieldInfo(annotation=bool, required=False, default=False)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- password: str | None
- port: int
- property redis_url: str
password@host:port/db`. (rediss://.. if TLS).
- Type:
a redis URL of form `redis
- Type:
//
- ssl: bool
