Skip to content

Commit

Permalink
Merge pull request #127 from synfinner/dev
Browse files Browse the repository at this point in the history
Add redis connection pool for cache
  • Loading branch information
synfinner authored Apr 14, 2024
2 parents 1d13e67 + a55079a commit 55dd3e3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/cache_config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Import the os module to interact with the operating system
import os

# Import redis so we can configure a connection pool
from redis import ConnectionPool

# Import the load_dotenv function from the python-dotenv module
from dotenv import load_dotenv
# Call the load_dotenv function to load environment variables from a .env file
load_dotenv()

# Get the value of the REDIS_IP environment variable
REDIS_IP = os.getenv("REDIS_IP")
pool = ConnectionPool(host=REDIS_IP, port=6379, max_connections=20, timeout=5)

# Define a dictionary to hold the configuration for the cache
cache_config = {
Expand All @@ -20,5 +24,7 @@
# Specify the port for the Redis server
'CACHE_REDIS_PORT': '6379',
# Specify a prefix for all keys stored in the cache
'CACHE_KEY_PREFIX': 'kev_'
'CACHE_KEY_PREFIX': 'kev_',
# Specify the Redis connection pool
'CACHE_REDIS_CONNECTION_POOL': pool
}

0 comments on commit 55dd3e3

Please sign in to comment.