Merge branch 'feature/cog-3142-agentic-use-case-kuzu-lock-fix-redis-integration' into feature/cog-3160-redis-session-conversation
This commit is contained in:
commit
36fd44dab2
3 changed files with 8 additions and 8 deletions
|
|
@ -15,7 +15,7 @@ class CacheDBInterface(ABC):
|
||||||
self.lock = None
|
self.lock = None
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def acquire(self):
|
def acquire_lock(self):
|
||||||
"""
|
"""
|
||||||
Acquire a lock on the given key.
|
Acquire a lock on the given key.
|
||||||
Must be implemented by subclasses.
|
Must be implemented by subclasses.
|
||||||
|
|
@ -23,7 +23,7 @@ class CacheDBInterface(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def release(self):
|
def release_lock(self):
|
||||||
"""
|
"""
|
||||||
Release the lock if it is held.
|
Release the lock if it is held.
|
||||||
Must be implemented by subclasses.
|
Must be implemented by subclasses.
|
||||||
|
|
@ -31,7 +31,7 @@ class CacheDBInterface(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def hold(self):
|
def hold_lock(self):
|
||||||
"""
|
"""
|
||||||
Context manager for safely acquiring and releasing the lock.
|
Context manager for safely acquiring and releasing the lock.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class RedisAdapter(CacheDBInterface):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.blocking_timeout = blocking_timeout
|
self.blocking_timeout = blocking_timeout
|
||||||
|
|
||||||
def acquire(self):
|
def acquire_lock(self):
|
||||||
"""
|
"""
|
||||||
Acquire the Redis lock manually. Raises if acquisition fails. (Sync because of Kuzu)
|
Acquire the Redis lock manually. Raises if acquisition fails. (Sync because of Kuzu)
|
||||||
"""
|
"""
|
||||||
|
|
@ -43,7 +43,7 @@ class RedisAdapter(CacheDBInterface):
|
||||||
|
|
||||||
return self.lock
|
return self.lock
|
||||||
|
|
||||||
def release(self):
|
def release_lock(self):
|
||||||
"""
|
"""
|
||||||
Release the Redis lock manually, if held. (Sync because of Kuzu)
|
Release the Redis lock manually, if held. (Sync because of Kuzu)
|
||||||
"""
|
"""
|
||||||
|
|
@ -55,7 +55,7 @@ class RedisAdapter(CacheDBInterface):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def hold(self):
|
def hold_lock(self):
|
||||||
"""
|
"""
|
||||||
Context manager for acquiring and releasing the Redis lock automatically. (Sync because of Kuzu)
|
Context manager for acquiring and releasing the Redis lock automatically. (Sync because of Kuzu)
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ class KuzuAdapter(GraphDBInterface):
|
||||||
lock_acquired = False
|
lock_acquired = False
|
||||||
try:
|
try:
|
||||||
if cache_config.shared_kuzu_lock:
|
if cache_config.shared_kuzu_lock:
|
||||||
self.redis_lock.acquire()
|
self.redis_lock.acquire_lock()
|
||||||
lock_acquired = True
|
lock_acquired = True
|
||||||
if not self.connection:
|
if not self.connection:
|
||||||
logger.info("Reconnecting to Kuzu database...")
|
logger.info("Reconnecting to Kuzu database...")
|
||||||
|
|
@ -252,7 +252,7 @@ class KuzuAdapter(GraphDBInterface):
|
||||||
try:
|
try:
|
||||||
self.close()
|
self.close()
|
||||||
finally:
|
finally:
|
||||||
self.redis_lock.release()
|
self.redis_lock.release_lock()
|
||||||
|
|
||||||
if cache_config.shared_kuzu_lock:
|
if cache_config.shared_kuzu_lock:
|
||||||
async with self._connection_change_lock:
|
async with self._connection_change_lock:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue