diff --git a/selfprivacy_api/services/__init__.py b/selfprivacy_api/services/__init__.py index 5a14d51..278896b 100644 --- a/selfprivacy_api/services/__init__.py +++ b/selfprivacy_api/services/__init__.py @@ -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( diff --git a/selfprivacy_api/utils/cached_call.py b/selfprivacy_api/utils/cached_call.py index 85a890d..c35d593 100644 --- a/selfprivacy_api/utils/cached_call.py +++ b/selfprivacy_api/utils/cached_call.py @@ -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) diff --git a/selfprivacy_api/utils/redis_pool.py b/selfprivacy_api/utils/redis_pool.py index 64f5758..bdad60e 100644 --- a/selfprivacy_api/utils/redis_pool.py +++ b/selfprivacy_api/utils/redis_pool.py @@ -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.