mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: use md5 hash of attributes/indexes instead of counts in cache key
Counts alone miss delete/re-add scenarios where the count stays the same but the schema is different. MD5 of the full attribute and index arrays captures any schema change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4d19a5e855
commit
d5b2f97252
+3
-5
@@ -142,18 +142,16 @@ class XList extends Action
|
||||
$hostname = $dbForProject->getAdapter()->getHostname();
|
||||
$roles = $dbForProject->getAuthorization()->getRoles();
|
||||
$collectionUpdatedAt = $collection->getAttribute('$updatedAt', '');
|
||||
$attributeCount = \count($collection->getAttribute('attributes', []));
|
||||
$indexCount = \count($collection->getAttribute('indexes', []));
|
||||
$schemaHash = \md5(\json_encode($collection->getAttribute('attributes', [])) . \json_encode($collection->getAttribute('indexes', [])));
|
||||
$cacheKeyBase = \sprintf(
|
||||
'%s-cache-%s:%s:%s:collection:%s:%s:%d:%d:user:%s:%s',
|
||||
'%s-cache-%s:%s:%s:collection:%s:%s:%s:user:%s:%s',
|
||||
$dbForProject->getCacheName(),
|
||||
$hostname ?? '',
|
||||
$dbForProject->getNamespace(),
|
||||
$dbForProject->getTenant(),
|
||||
$collectionId,
|
||||
$collectionUpdatedAt,
|
||||
$attributeCount,
|
||||
$indexCount,
|
||||
$schemaHash,
|
||||
\md5(\json_encode($roles)),
|
||||
\md5(\json_encode($serializedQueries))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user