Skip to content

Refactor: extract Valkey Del command and ratelimit ring client injection - #4158

Draft
larry-dalmeida wants to merge 4 commits into
zalando:masterfrom
larry-dalmeida:feat/valkey-del-ratelimit-ring-refactor
Draft

Refactor: extract Valkey Del command and ratelimit ring client injection#4158
larry-dalmeida wants to merge 4 commits into
zalando:masterfrom
larry-dalmeida:feat/valkey-del-ratelimit-ring-refactor

Conversation

@larry-dalmeida

@larry-dalmeida larry-dalmeida commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Related Issue

Prerequisite PR for #4033, extracted to reduce the size of the cache filter PR.

Summary

  • net/valkey.go: adds Del method to valkeyRing and ValkeyRingClient; fixes SetWithExpire empty-result guard ordering (guard-before-loop for clarity)
  • ratelimit/redis.go / ratelimit/valkey.go: exports RedisMetricsPrefix and ValkeyMetricsPrefix constants so callers outside the package can reference them
  • ratelimit/registry.go: introduces NewRatelimitRegistryRedis and NewRatelimitRegistryValkey - injectable constructors that accept a pre-created ring client, enabling ring reuse across subsystems
  • skipper.go: creates the shared valkeyRing once and passes it to both the ratelimit registry and (in feat: L2 Cache with Valkey Client Side Hash Ring #4033) the cache filter, replacing the old NewSwarmRegistry call

szuecs and others added 3 commits July 27, 2026 12:08
…we can reuse the valkey ring client in the cache filter creation.

Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
The len(results)==0 check was placed after the error-checking for-loop,
making it read as dead code. Reorder to guard-first for clarity: validate
non-empty results, then iterate to check for errors from the SET and EXPIRE
commands, then return success.

Signed-off-by: larry-dalmeida <hello@larrydalmeida.com>
Replace the EXPIRE key -1 workaround in ValkeyStorage.Delete() with a proper
DEL command. This eliminates the 'hack' comment that szuecs flagged in
comment r3501815470.

Changes:
- Add Del() method to valkeyRing (net/valkey.go)
- Add Del() method to ValkeyRingClient (net/valkey.go)
- Add Del() to the valkeyClient interface (filters/cache/valkey_storage.go)
- Update Delete() to use Del instead of Expire key -1 (filters/cache/valkey_storage.go)
- Add Del() to stubValkeyClient test stub (filters/cache/valkey_storage_test.go)

This makes the code more idiomatic and removes the complexity of the
EXPIRE key -1 semantics workaround.

Signed-off-by: larry-dalmeida <hello@larrydalmeida.com>
@larry-dalmeida larry-dalmeida changed the title refactor: extract Valkey Del command and ratelimit ring client injection Refactor: extract Valkey Del command and ratelimit ring client injection Jul 27, 2026
The cache.NewCacheFilter block was carried over from the cherry-pick
of f23acb2 but belongs exclusively in PR zalando#4033, which introduces the
cache filter with full Options-struct wiring. This prereq only provides
the shared valkeyRing creation and ratelimit registry injection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants