mirror of
https://github.com/penpot/penpot.git
synced 2026-08-29 16:18:48 +00:00
🐛 Include tenant in library summary cache keys
The redis cache keys for the file library summary were built as penpot.library-summary.<file-id>, 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.<tenant>.<file-id> 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
This commit is contained in:
parent
38004e6bb2
commit
948a97cc54
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user