From 2640e419bfa3d3570ab3761b192291047b42393e Mon Sep 17 00:00:00 2001 From: shimon Date: Fri, 31 May 2024 08:27:49 +0300 Subject: [PATCH] refactor:cache flow --- src/Database/Database.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index d147c3944..6534af0a4 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -2786,9 +2786,8 @@ public function getDocument(string $collection, string $id, array $queries = []) if (!$hasTwoWayRelationship && empty($relationships)) { $this->cache->save($documentCacheHash.'---'.$documentCacheKey, $document->getArrayCopy()); //add document reference to the collection hash - var_dump('Saving '.$collectionCacheHash.'---'.$documentCacheHash); - $bla = $this->cache->save($collectionCacheHash.'---'.$documentCacheHash, 'bla'); - var_dump($bla); + $this->cache->save($collectionCacheHash.'---'.$documentCacheHash, 'empty'); + } // Remove internal attributes if not queried for select query @@ -4749,6 +4748,8 @@ public function purgeCachedCollection(string $collection): bool */ public function purgeCachedDocument(string $collection, string $id): bool { + $collectionCacheHash = $this->cacheName . '-cache-' . $this->getNamespace() . ':' . $this->adapter->getTenant() . ':' . $collection . ':collection'; + // Todo we should implement HDEL on the collection return $this->cache->purge($this->cacheName . '-cache-' . $this->getNamespace() . ':' . $this->adapter->getTenant() . ':' . $collection . ':' . $id); }