my_redis.py 431 B

12345678910111213141516
  1. import redis
  2. from app.core.config import settings
  3. class MyRedis:
  4. def __init__(self) -> None:
  5. self._host = settings.REDIS_HOST
  6. self._port = settings.REDIS_PORT
  7. self._db = settings.REDIS_DB
  8. self._password = settings.REDIS_PASSWORD
  9. def get_client(self) -> redis.Redis:
  10. return redis.Redis(
  11. host=self._host, port=self._port, db=self._db, password=self._password
  12. )