Skip to content

Commit 3912946

Browse files
committed
Refactor setCacheKey method: improve cache key generation by switching to xxh3 hash and enhancing JSON encode options.
1 parent 2d238aa commit 3912946

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Mvc/Controller/Traits/Query/Cache.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ public function initializeCacheKey(): void
100100
$this->getModelName(),
101101
$this->getCacheLifetime(),
102102
$this->identity->getUserId(),
103-
md5(json_encode($this->getParams()) ?: ''),
104103
]);
105-
$cacheKey = '_' . implode('-', $cacheKeys) . '_';
106-
$this->setCacheKey($cacheKey);
104+
105+
$jsonParams = json_encode($this->getParams(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
106+
if (!empty($jsonParams)) {
107+
$cacheKeys[] = hash('xxh3', $jsonParams);
108+
}
109+
110+
$this->setCacheKey('_' . implode('-', $cacheKeys) . '_');
107111
}
108112

109113
/**

0 commit comments

Comments
 (0)