This commit is contained in:
Inex Code 2024-12-21 21:18:09 +03:00
parent e62bd2b2e7
commit 6ccdb27792
No known key found for this signature in database
3 changed files with 10 additions and 3 deletions

View file

@ -263,7 +263,7 @@ def get_templated_service(service_id: str) -> TemplatedService:
@redis_cached_call(ttl=3600)
def get_remote_service(url: str, id: str) -> TemplatedService:
def get_remote_service(id: str, url: str) -> TemplatedService:
# Get JSON from calling the sp-fetch-remote-module command with the URL
# Parse the JSON into a TemplatedService object
response = subprocess.run(

View file

@ -8,7 +8,7 @@ CACHE_PREFIX = "exec_cache:"
def get_redis_object(key: str) -> Optional[Any]:
redis = RedisPool().get_connection()
redis = RedisPool().get_raw_connection()
binary_obj = redis.get(key)
if binary_obj is None:
return None
@ -16,7 +16,7 @@ def get_redis_object(key: str) -> Optional[Any]:
def save_redis_object(key: str, obj: Any, expire: Optional[int] = 60) -> None:
redis = RedisPool().get_connection()
redis = RedisPool().get_raw_connection()
binary_obj = pickle.dumps(obj)
if expire:
redis.setex(key, expire, binary_obj)

View file

@ -29,6 +29,7 @@ class RedisPool:
url,
decode_responses=True,
)
self._raw_pool = redis.ConnectionPool.from_url(url)
@staticmethod
def connection_url(dbnumber: int) -> str:
@ -44,6 +45,12 @@ class RedisPool:
"""
return redis.Redis(connection_pool=self._pool)
def get_raw_connection(self):
"""
Get a raw connection from the pool.
"""
return redis.Redis(connection_pool=self._raw_pool)
def get_connection_async(self) -> redis_async.Redis:
"""
Get an async connection from the pool.