From 948a97cc54da042840e00d527d5a0759f31f4fed Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 28 Aug 2026 08:44:45 +0000 Subject: [PATCH] :bug: Include tenant in library summary cache keys The redis cache keys for the file library summary were built as penpot.library-summary., missing the tenant component used by the rest of the shared-infrastructure keys (rlimit, msgbus, worker queues). Build the key with a new file-summary-cache-key function that appends the configured tenant, following the penpot.library-summary.. pattern. Stale keys in the old format expire on their own with the existing 30-day TTL. Closes #11407 AI-assisted-by: glm-5.3-flash --- backend/src/app/rpc/commands/files.clj | 9 ++++++--- backend/src/app/rpc/commands/files_update.clj | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 412da68667..e6a6e71012 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -515,8 +515,11 @@ (def ^:private file-summary-cache-key-ttl (ct/duration {:days 30})) -(def file-summary-cache-key-prefix - "penpot.library-summary.") +(defn file-summary-cache-key + "Build the redis cache key for the file library summary. The tenant is + included to prevent key collisions between tenants sharing a redis instance" + [id] + (str "penpot.library-summary." (cf/get :tenant) "." id)) (defn- get-file-with-summary "Get a file without data with a summary of its local library content" @@ -545,7 +548,7 @@ (rds/build-set-args {:ex file-summary-cache-key-ttl})))] (if (contains? cf/flags :redis-cache) - (let [cache-key (str file-summary-cache-key-prefix id)] + (let [cache-key (file-summary-cache-key id)] (or (rds/run! cfg get-from-cache cache-key) (let [file (calculate-from-db)] (rds/run! cfg persist-to-cache (:library-summary file) cache-key) diff --git a/backend/src/app/rpc/commands/files_update.clj b/backend/src/app/rpc/commands/files_update.clj index 8313c61f63..519a32ba07 100644 --- a/backend/src/app/rpc/commands/files_update.clj +++ b/backend/src/app/rpc/commands/files_update.clj @@ -322,7 +322,7 @@ (defn- invalidate-caches! [cfg {:keys [id] :as file}] (rds/run! cfg (fn [{:keys [::rds/conn]}] - (let [key (str files/file-summary-cache-key-prefix id)] + (let [key (files/file-summary-cache-key id)] (rds/del conn key))))) (defn- attach-snapshot