docs(adr): pluggable distributed cache (ADR 0002)#31
Merged
Conversation
Design for a devslab.kit.cache.* block with a type switch (none / in-memory / redis) where flipping one property turns a single-node cache into a correct distributed one — and the kit owns the Redis JSON serialization so consumers never touch it or hit SerializationException. The existing hand-rolled menu cache becomes the first consumer of the shared CacheManager; the consumer's own @Cacheable methods get distributed caching for free. Design-only; bilingual.
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.
Design-only PR (like #28 was for bootstrap). Captures the distributed-cache decision before any code.
The idea (your call from this session)
A consumer flips one property to turn the cache from in-memory to distributed (Redis), and never touches serialization. Their own
@Cacheablemethods just work across replicas.Why
ConcurrentHashMap— breaks on >1 replica (stale on every node but the writer until TTL lapses).Serializablerequirement,SerializationException, hand-configuring JSON + safe default-typing). A platform starter should decide that once.What the ADR proposes
devslab.kit.cache.typeswitch →CacheManagerbean (none / in-memory / redis), each conditionally wired; consumer's ownCacheManageralways wins.GenericJackson2JsonRedisSerializer+ a safe default-typingObjectMapper(noLaissezFaireSubTypeValidator). This is the headline value.-cache-api/-cache-coremodules; Redis stays optional & non-transitive (in-memory default keeps zero-dependency simple path).CacheManager— one cache story, and it stops being a multi-replica bug.@Cacheableon their own code for free.Plan (4 PRs)
cache-api/core + autoconfig → Redis path + serialization (real-Redis Testcontainers round-trip test) → migrate menu cache → sample-app(
type=redison the compose Redis it already starts) + docs.Targeted for v0.1.0 (decided: cache first, then release).
Sign-off needed
typeswitch shape + property names.@EnableCachingby default (guarded by@ConditionalOnMissingBean)?Once you're happy I'll flip Status → Accepted and start PR 1.