Repository navigation
fix(redis): isolate chat memory key prefixes per repository - #71
Merged
yuluo-yx merged 1 commit intoOct 30, 2026
Merged
Conversation
Capture each repository's prefix at construction instead of mutating shared static configuration. Cover all client pairings, failed and parallel builds, builder reuse, and actual Redis keys. Document compatibility and migration considerations. Fixes agentic-ai-java#50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
Redis chat-memory repositories currently share a mutable static key prefix. Constructing a second Jedis, Lettuce, or Redisson repository changes the keys used by an existing repository; even a failed build can change its namespace.
This PR captures the prefix in an immutable instance field so each repository consistently uses its configured namespace.
Does this pull request fix one issue?
Fixes #50
Describe how you did it
argi_chat_memory:<conversationId>format, null-to-default behavior, explicitly empty prefixes, and intentional sharing between instances with the same prefix.Describe how to verify it
With an isolated Redis available on port 16379:
mvn -B -ntp -pl memory-repository/argi-model-chat-memory-repository-redis -am \ -Dtest=RedisKeyPrefixIsolationTest,RedisKeyPrefixIntegrationTest \ -Dredis.test.port=16379 -Dcheckstyle.skip=false testThe integration suite alternatively starts a Redis container when Docker is available. Test keys use unique IDs; the suite does not flush the database.
Verified locally with JDK 21 and a temporary standalone Redis 7.0.15 server:
git diff --checkpassed.Special notes for reviews
Seven files change: four production classes, two test classes, and the existing README. No changes to serialization, SSL, or
saveAllatomicity are included.The protected mutable static
CUSTOM_KEY_PREFIXfield is removed. External subclasses using that field must migrate tosuper(keyPrefix)and recompile. The public no-argument base constructor and protectedgetKeyPrefix()method remain available; public builder methods are unchanged.Applications previously affected by cross-instance prefix changes should audit known namespaces against authoritative ownership records before migrating any data. Prefixes are not an authorization boundary. The real-backend verification covers standalone Redis, not TLS, Redis Cluster, or high availability.