feat(cache): pluggable CacheManager via devslab.kit.cache.type (ADR 0002 PR 1)#32
Merged
Conversation
…002 PR 1) Introduces the cache infrastructure from ADR 0002 (now Accepted). A consumer flips one property to choose the backing store; the kit owns the CacheManager and turns on Spring's caching annotations so the consumer's own @Cacheable methods just work. New modules - devslab-kit-cache-api: CacheNames constants (kit-internal cache names). - devslab-kit-cache-core: CacheType (none/in-memory/redis), CacheProperties (devslab.kit.cache.*), CacheAutoConfiguration. CacheAutoConfiguration - type=none → NoOpCacheManager; type=in-memory (default) → ConcurrentMapCacheManager. - @EnableCaching turned on, but guarded by @ConditionalOnMissingBean(CacheManager) so a consumer who manages caching themselves always wins. - RedisCacheConfiguration is imported but a deliberate no-op scaffold in this PR (guards in place); the real RedisCacheManager + safe-default-typing JSON serialization land in PR 2 with a real-Redis Testcontainers round-trip test. - Redis is compileOnly in -cache-core, so it never becomes a transitive dependency — the in-memory default stays zero-dependency (ADR 0002 §4). Wiring - settings.gradle.kts: include the two new modules. - autoconfigure depends on -cache-api/-cache-core. Tests - CacheAutoConfigurationTest (ApplicationContextRunner): default in-memory, explicit in-memory, none→NoOp, disabled→no bean, consumer-bean-wins, property binding. Registered as a plain user config (not AutoConfigurations.of) because SB4 splits that helper's package across two jars; see the test javadoc. Docs: ADR 0002 flipped Proposed → Accepted with the implementation note.
PR 1's settings include() edit never made it to disk (it was in a cancelled tool batch I mistakenly thought had applied), so the two new cache modules were absent from the build. Local --no-daemon passed off a stale daemon/cache state; CI's fresh checkout failed with 'Project :devslab-kit-cache-api could not be found'. Added the includes; verified with daemon stopped + ./gradlew build --no-daemon (BUILD SUCCESSFUL, fresh).
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.
First of 4 PRs implementing ADR 0002 (now Accepted). Lands the cache infrastructure + the
typeswitch; Redis serialization, menu-cache migration, and sample-app/docs follow.What
devslab-kit-cache-api(CacheNames) +devslab-kit-cache-core(CacheType, CacheProperties, CacheAutoConfiguration).type=none→NoOpCacheManager;type=in-memory(default) →ConcurrentMapCacheManager.@EnableCachingturned on but guarded by@ConditionalOnMissingBean(CacheManager)— a consumer who manages caching themselves always wins.compileOnlyin -cache-core → never a transitive dependency; in-memory default keeps the zero-dependency path (ADR 0002 §4).RedisCacheConfigurationis a guarded no-op scaffold here; the realRedisCacheManager+ safe-default-typing JSON serialization land in PR 2 with a real-Redis Testcontainers round-trip test (serialization is the risk, so it gets its own tested PR).Tests
CacheAutoConfigurationTest(ApplicationContextRunner): default in-memory · explicit in-memory · none→NoOp · disabled→no bean · consumer-bean-wins · property binding. Registered as a plain user config rather thanAutoConfigurations.of(...)because SB4 splits that helper's package across two jars ("package not visible") — noted in the test javadoc.Verification
./gradlew build --no-daemongreen (fresh, CI parity); cache modules confirmed in the build graph + autoconfigure dependency.Sign-off note
@EnableCachingon-by-default was approved in the ADR thread (guarded). No behaviour change for existing consumers — default is in-memory, same single-node semantics as today's menu cache (which migrates onto this in PR 3).