Skip to content

[Upstream] fix: invalidate group_models Redis cache on channel create/update/delete#124

Open
Sagit-chu wants to merge 1 commit into
mainfrom
upstream-pr-2381
Open

[Upstream] fix: invalidate group_models Redis cache on channel create/update/delete#124
Sagit-chu wants to merge 1 commit into
mainfrom
upstream-pr-2381

Conversation

@Sagit-chu

Copy link
Copy Markdown
Owner

Synced from upstream PR: songquanpeng#2381

Fixes songquanpeng#2327

Problem

When a channel is created, updated, or its enabled/disabled status is changed, the Redis group_models:{group} cache key is not invalidated. Because this cache has a TTL equal to SYNC_FREQUENCY (default 10 minutes), users who create a new channel must wait up to 10 minutes before the channel's models appear in the token model-scope selector (/api/user/available_models). During this time, searching for the newly added model (e.g. gemini-2.5-pro) returns no results in the dropdown.

Solution

Add ClearGroupModelsCacheByGroups(groups []string) to model/cache.go that deletes the relevant Redis keys for the affected groups. Call it:

  • In AddAbilities() after successfully inserting ability rows (channel create)
  • In DeleteAbilities() after successfully deleting ability rows (channel delete / update)
  • In UpdateChannelStatusById() after changing channel status (channel enable/disable)

UpdateAbilities() already delegates to DeleteAbilities + AddAbilities, so channel updates are covered automatically.

No-op when Redis is not enabled.

Testing

  • Reproduced by: create a channel, immediately query /api/user/available_models — with the fix the new model appears immediately; without it the old cache is still returned.
  • Build verified: go build ./... succeeds.

…delete (fixes songquanpeng#2327)

When a channel is created, updated, or its status changed, the Redis
group_models:{group} cache was not invalidated. This meant users had
to wait up to SYNC_FREQUENCY seconds (default 10 min) before newly
added channel models appeared in the token model-scope selector.

Add ClearGroupModelsCacheByGroups to model/cache.go and call it from
AddAbilities, DeleteAbilities (which UpdateAbilities delegates to), and
UpdateChannelStatusById so the stale cache entry is evicted immediately
after each change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OneAPI 0.6.11调用Gemini出错

1 participant