summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/cache.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-08-30 12:08:31 +0100
committerdakkar <dakkar@thenautilus.net>2024-08-30 12:08:31 +0100
commit6151099f5ba07d14a651aea8f816dd280d74209d (patch)
tree4b014a2f4b198facc8bdd92c70b49fec2801d51a /packages/backend/src/misc/cache.ts
parentmerge: thunk the min/max promises (!603) (diff)
parentMerge pull request #14391 from misskey-dev/develop (diff)
downloadsharkey-6151099f5ba07d14a651aea8f816dd280d74209d.tar.gz
sharkey-6151099f5ba07d14a651aea8f816dd280d74209d.tar.bz2
sharkey-6151099f5ba07d14a651aea8f816dd280d74209d.zip
Merge remote-tracking branch 'misskey/master' into feature/misskey-2024.8
Diffstat (limited to 'packages/backend/src/misc/cache.ts')
-rw-r--r--packages/backend/src/misc/cache.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts
index d968069ca3..f9692ce5d5 100644
--- a/packages/backend/src/misc/cache.ts
+++ b/packages/backend/src/misc/cache.ts
@@ -72,6 +72,10 @@ export class RedisKVCache<T> {
/**
* キャッシュがあればそれを返し、無ければfetcherを呼び出して結果をキャッシュ&返します
+ * This awaits the call to Redis to ensure that the write succeeded, which is important for a few reasons:
+ * * Other code uses this to synchronize changes between worker processes. A failed write can internally de-sync the cluster.
+ * * Without an `await`, consecutive calls could race. An unlucky race could result in the older write overwriting the newer value.
+ * * Not awaiting here makes the entire cache non-consistent. The prevents many possible uses.
*/
@bindThis
public async fetch(key: string): Promise<T> {
@@ -172,6 +176,10 @@ export class RedisSingleCache<T> {
/**
* キャッシュがあればそれを返し、無ければfetcherを呼び出して結果をキャッシュ&返します
+ * This awaits the call to Redis to ensure that the write succeeded, which is important for a few reasons:
+ * * Other code uses this to synchronize changes between worker processes. A failed write can internally de-sync the cluster.
+ * * Without an `await`, consecutive calls could race. An unlucky race could result in the older write overwriting the newer value.
+ * * Not awaiting here makes the entire cache non-consistent. The prevents many possible uses.
*/
@bindThis
public async fetch(): Promise<T> {