Repository navigation
Add Valkey 9.0 MemcacheService backed by valkey-glide - #527
Conversation
Implements ValkeyCacheService using the native SET ... IFEQ comparison-value [EX seconds] command introduced in Valkey 8.1/9.0, so CAS is a single round trip per key instead of a WATCH/MULTI/EXEC dance. Cold-cache reads bootstrap a single-byte 0x00 null sentinel via SET NX (the sentinel cannot collide with Java-serialized data, which always begins 0xAC 0xED). Adds TestContainers-based extensions and ports BasicCache, Caching, CachingDatastore, CachingUncacheable, and EvilMemcacheBug tests to run against a real valkey/valkey:9.0 container. Includes a new ValkeyCacheServiceTests with direct coverage of the null sentinel, cold-cache bootstrap, CAS win/lose/replace/partial-success, native EX expiration, and a multi-threaded contention test asserting exactly one CAS winner. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@stickfigure Not sure if you're working any on objectify these days, but Google announced that they're sunsetting Memorystore (Memcache) albeit on a multi-year timeline. The replacement is Valkey, which is AWS rebrand of Redis. Valkey's added direct support for CAS, so figured I'd just add in support for that. This PR is mostly via Claude. I've reviewed it at a high level and seems reasonable, but wanted to see if you 1) had interest in this upstream or preferred us just to maintain it for the time being and 2) if you had a preference on sequencing for testing/etc (happy to run with it, deploy at Streak and get prod testing, then come back). |
|
@frew looks good to me. Merged and interested in the upstream - let me know if you're happy about it, I can merge changes and when you greenlight it roll a release. |
Builds on the initial ValkeyCacheService (PR objectify#527) with three changes: - Cluster-safe: hold the client as a BaseClient (standalone GlideClient or GlideClusterClient). Multi-key operations are issued as concurrent per-key commands instead of MGET/MSET/DEL, which would fail with CROSSSLOT on a cluster. CAS commands are routed to the primary owning the key's slot via SlotKeyRoute. - Bounded keyspace: every write carries a TTL, falling back to a configurable defaultExpirationSeconds (default 24h) when the entity declares no expiration. A noeviction cluster cannot shed cold entries via LRU the way memcache does, so unbounded writes would eventually exhaust maxmemory and fail all writers with OOM. Covers plain puts, the cold-cache null sentinel, and CAS writes with no explicit TTL. - Pre-build the default SetOptions once instead of allocating a builder on every put/putAll, and add a constructor taking an explicit TTL. Squashed from the StreakYC/objectify streak-valkey branch, excluding the fork's release-versioning and Artifact Registry publishing changes.
Implements ValkeyCacheService using the native SET ... IFEQ comparison-value [EX seconds] command introduced in Valkey 8.1/9.0, so CAS is a single round trip per key instead of a WATCH/MULTI/EXEC dance. Cold-cache reads bootstrap a single-byte 0x00 null sentinel via SET NX (the sentinel cannot collide with Java-serialized data, which always begins 0xAC 0xED).
Adds TestContainers-based extensions and ports BasicCache, Caching, CachingDatastore, CachingUncacheable, and EvilMemcacheBug tests to run against a real valkey/valkey:9.0 container. Includes a new ValkeyCacheServiceTests with direct coverage of the null sentinel, cold-cache bootstrap, CAS win/lose/replace/partial-success, native EX expiration, and a multi-threaded contention test asserting exactly one CAS winner.