TDD: 1, Me: 0
This commit is contained in:
14
app/redis_config.py
Normal file
14
app/redis_config.py
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
Reference in New Issue
Block a user