mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-25 10:32:22 +08:00
feat: inmemory and async cache expire configurable (#2496)
inmemory and async cache expire configurable
This commit is contained in:
@ -28,10 +28,11 @@ class CacheServiceFactory(ServiceFactory):
|
||||
if redis_cache.is_connected():
|
||||
logger.debug("Redis cache is connected")
|
||||
return redis_cache
|
||||
logger.warning("Redis cache is not connected, falling back to in-memory cache")
|
||||
return AsyncInMemoryCache()
|
||||
else:
|
||||
# do not attempt to fallback to another cache type
|
||||
raise ConnectionError("Failed to connect to Redis cache")
|
||||
|
||||
elif settings_service.settings.cache_type == "memory":
|
||||
return ThreadingInMemoryCache()
|
||||
return ThreadingInMemoryCache(expiration_time=settings_service.settings.cache_expire)
|
||||
elif settings_service.settings.cache_type == "async":
|
||||
return AsyncInMemoryCache()
|
||||
return AsyncInMemoryCache(expiration_time=settings_service.settings.cache_expire)
|
||||
|
||||
@ -74,6 +74,8 @@ class Settings(BaseSettings):
|
||||
"""The number of connections to allow that can be opened beyond the pool size. If not provided, the default is 10."""
|
||||
cache_type: str = "async"
|
||||
"""The cache type can be 'async' or 'redis'."""
|
||||
cache_expire: int = 3600
|
||||
"""The cache expire in seconds."""
|
||||
variable_store: str = "db"
|
||||
"""The store can be 'db' or 'kubernetes'."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user