Files
Xiyuan Chen 0b66639aba feat(cache): cache the tenant model provider list in the daemon (#780)
* fix(parser): let UnmarshalJson return slice payloads

validator.Struct rejects any non-struct top-level value, so UnmarshalJson
with a slice T always failed before returning. Skip validation for slices
alongside maps and strings.

UnmarshalJsonBytes2Slice remains the variant that validates per element.

* feat(cache): cache tenant model installations in the daemon

Dify caches the per-tenant model provider list, but enterprise installs
plugins through the daemon directly, so Dify never learns its cache is
stale and a newly assigned plugin stays invisible until the TTL expires.

Move the cache to where the writes happen. ListModels now reads through a
Redis hash keyed per tenant, with the page as the field so a single DEL
drops every cached page, and InstallPlugin/UninstallPlugin/UpgradePlugin
invalidate it.

The invalidation is deferred rather than run after the transaction: a
retried install aborts on ErrPluginAlreadyInstalled before reaching any
post-transaction code, so a DEL placed there is unreachable once it has
failed once.

TTL defaults to 60 minutes, configurable via
PLUGIN_MODEL_INSTALLATIONS_CACHE_TTL.

* Update PLUGIN_MODEL_INSTALLATIONS_CACHE_TTL value

* Increase PluginModelInstallationsCacheTTL to 1440

* feat(cache): put the model installations cache behind a switch, off by default

The daemon cache holds the same tenant payload dify already caches, so leaving
both on doubles the redis footprint and forces a scale-up before a cloud
production rollout. PLUGIN_MODEL_INSTALLATIONS_CACHE_ENABLED defaults to false;
enable it only where dify runs with PLUGIN_MODEL_PROVIDERS_CACHE_ENABLED=false.
2026-07-28 02:01:23 -07:00
..
2026-04-07 09:53:29 +08:00