mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-30 04:36:39 +00:00
fixes
This commit is contained in:
parent
e62bd2b2e7
commit
6ccdb27792
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue