feat: adds redis locks
This commit is contained in:
parent
c72c4c56b9
commit
466707b003
1 changed files with 4 additions and 2 deletions
|
|
@ -225,22 +225,24 @@ class KuzuAdapter(GraphDBInterface):
|
|||
logger.error(f"Query execution failed: {str(e)}")
|
||||
raise
|
||||
|
||||
if not cache_config.caching:
|
||||
if cache_config.caching:
|
||||
async with self._connection_change_lock:
|
||||
self.open_connections += 1
|
||||
if self._is_closed:
|
||||
self.redis_lock.acquire()
|
||||
self.reopen()
|
||||
logger.info(f"Open connections after open: {self.open_connections}")
|
||||
|
||||
result = await loop.run_in_executor(self.executor, blocking_query)
|
||||
|
||||
if not cache_config.caching:
|
||||
if cache_config.caching:
|
||||
async with self._connection_change_lock:
|
||||
self.open_connections -= 1
|
||||
logger.info(f"Opened connections after closing {self.open_connections}")
|
||||
if self.open_connections == 0:
|
||||
self.connection.execute("CHECKPOINT;")
|
||||
self.close()
|
||||
self.redis_lock.release()
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue