From c882afbd2c1becdc601d47eb3416e5bb966db14a Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 6 Jan 2026 12:52:36 +0200 Subject: [PATCH] Enhance XList class by injecting user dependency and updating cache key format to include user ID for improved caching accuracy. --- .../Http/Databases/Collections/Documents/XList.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php index fcec52066a..35a1ac4fe9 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php @@ -75,13 +75,14 @@ class XList extends Action ->param('ttl', 30, new Range(min: 1, max: 86400), 'TTL (seconds) for cached respnses when caching is enabled. Must be between 1 and 86400 (24 hours).', true) ->inject('response') ->inject('dbForProject') + ->inject('user') ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, array $queries, ?string $transactionId, bool $includeTotal, bool $cache, int $ttl, UtopiaResponse $response, Database $dbForProject, StatsUsage $queueForStatsUsage, TransactionState $transactionState, Authorization $authorization): void + public function action(string $databaseId, string $collectionId, array $queries, ?string $transactionId, bool $includeTotal, bool $cache, int $ttl, UtopiaResponse $response, Database $dbForProject, Document $user, StatsUsage $queueForStatsUsage, TransactionState $transactionState, Authorization $authorization): void { $isAPIKey = User::isApp($authorization->getRoles()); $isPrivilegedUser = User::isPrivileged($authorization->getRoles()); @@ -146,13 +147,15 @@ class XList extends Action } $hostname = $dbForProject->getAdapter()->getHostname(); + $userId = $user->getId() ?? ''; $cacheKeyBase = \sprintf( - '%s-cache-%s:%s:%s:collection:%s:%s', + '%s-cache-%s:%s:%s:collection:%s:user:%s:%s', $dbForProject->getCacheName(), $hostname ?? '', $dbForProject->getNamespace(), $dbForProject->getTenant(), $collectionId, + $userId, \md5(\json_encode($serializedQueries)) );