Add Redis URL configuration option
This commit is contained in:
parent
4a9c7506ea
commit
955ef77060
3 changed files with 11 additions and 7 deletions
|
|
@ -22,6 +22,7 @@ class CacheServiceFactory(ServiceFactory):
|
||||||
host=settings_service.settings.REDIS_HOST,
|
host=settings_service.settings.REDIS_HOST,
|
||||||
port=settings_service.settings.REDIS_PORT,
|
port=settings_service.settings.REDIS_PORT,
|
||||||
db=settings_service.settings.REDIS_DB,
|
db=settings_service.settings.REDIS_DB,
|
||||||
|
url=settings_service.settings.REDIS_URL,
|
||||||
expiration_time=settings_service.settings.REDIS_CACHE_EXPIRE,
|
expiration_time=settings_service.settings.REDIS_CACHE_EXPIRE,
|
||||||
)
|
)
|
||||||
if redis_cache.is_connected():
|
if redis_cache.is_connected():
|
||||||
|
|
|
||||||
16
src/backend/langflow/services/cache/service.py
vendored
16
src/backend/langflow/services/cache/service.py
vendored
|
|
@ -1,14 +1,13 @@
|
||||||
|
import pickle
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from langflow.services.base import Service
|
|
||||||
|
|
||||||
from langflow.services.cache.base import BaseCacheService
|
|
||||||
|
|
||||||
import pickle
|
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
from langflow.services.base import Service
|
||||||
|
from langflow.services.cache.base import BaseCacheService
|
||||||
|
|
||||||
|
|
||||||
class InMemoryCache(BaseCacheService, Service):
|
class InMemoryCache(BaseCacheService, Service):
|
||||||
|
|
||||||
|
|
@ -204,7 +203,7 @@ class RedisCache(BaseCacheService, Service):
|
||||||
b = cache["b"]
|
b = cache["b"]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="localhost", port=6379, db=0, expiration_time=60 * 60):
|
def __init__(self, host="localhost", port=6379, db=0, url=None, expiration_time=60 * 60):
|
||||||
"""
|
"""
|
||||||
Initialize a new RedisCache instance.
|
Initialize a new RedisCache instance.
|
||||||
|
|
||||||
|
|
@ -226,7 +225,10 @@ class RedisCache(BaseCacheService, Service):
|
||||||
"RedisCache is an experimental feature and may not work as expected."
|
"RedisCache is an experimental feature and may not work as expected."
|
||||||
" Please report any issues to our GitHub repository."
|
" Please report any issues to our GitHub repository."
|
||||||
)
|
)
|
||||||
self._client = redis.StrictRedis(host=host, port=port, db=db)
|
if url:
|
||||||
|
self._client = redis.StrictRedis.from_url(url)
|
||||||
|
else:
|
||||||
|
self._client = redis.StrictRedis(host=host, port=port, db=db)
|
||||||
self.expiration_time = expiration_time
|
self.expiration_time = expiration_time
|
||||||
|
|
||||||
# check connection
|
# check connection
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class Settings(BaseSettings):
|
||||||
REDIS_HOST: str = "localhost"
|
REDIS_HOST: str = "localhost"
|
||||||
REDIS_PORT: int = 6379
|
REDIS_PORT: int = 6379
|
||||||
REDIS_DB: int = 0
|
REDIS_DB: int = 0
|
||||||
|
REDIS_URL: Optional[str] = None
|
||||||
REDIS_CACHE_EXPIRE: int = 3600
|
REDIS_CACHE_EXPIRE: int = 3600
|
||||||
|
|
||||||
# PLUGIN_DIR: Optional[str] = None
|
# PLUGIN_DIR: Optional[str] = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue