Files
WOL-LY/app/redis_config.py
2024-12-13 18:08:44 +02:00

15 lines
527 B
Python

from redis import from_url, ConnectionPool, Redis
# Set up Redis connection for Flask-Limiter
def setup_redis(app):
try:
pool = ConnectionPool.from_url(app.config['REDIS_URL'])
redis_connection = Redis(connection_pool=pool)
redis_connection.ping()
app.logger.info("Connected to Redis")
# Return the redis_connection to be used elsewhere
return redis_connection
except Exception as e:
app.logger.error(f"Failed to connect to Redis: {str(e)}")
return None