Files
meldestelle/infrastructure/cache/cache-api/build.gradle.kts
T
stefan 7592adfbb5 refactor(infra-cache): Refine module with Kotlin idioms and robust tests
This commit introduces a comprehensive refactoring of the cache module to improve code consistency, API ergonomics, and test robustness.

Code Refinements & Improvements
Standardized on kotlin.time: Replaced all usages of java.time.Instant and java.time.Duration with their kotlin.time counterparts (Instant, Duration). This aligns the module with the project-wide standard established in the core module and avoids type conversions.

Added Idiomatic Kotlin API: Introduced inline extension functions with reified type parameters for get() and multiGet(). This allows for a cleaner, more type-safe call syntax (e.g., cache.get<User>("key")) for Kotlin consumers.

Code Cleanup: Removed redundant @OptIn(ExperimentalTime::class) annotations from data classes by setting the compiler option at the module level in cache-api/build.gradle.kts.

Testing Enhancements
Stabilized Offline-Mode Tests: Re-implemented the previously disabled offline capability tests. The new approach uses MockK to simulate RedisConnectionFailureException instead of trying to stop/start the Testcontainer. This allows for reliable and robust testing of the "dirty key" synchronization logic.

Fixed Compilation Errors: Resolved various compilation errors in the test suite that arose from the type refactoring and incorrect mock setups.
2025-08-09 14:57:44 +02:00

24 lines
767 B
Kotlin

// Dieses Modul definiert die provider-agnostische Caching-API.
// Es enthält nur Interfaces (z.B. `CacheService`) und Datenmodelle,
// aber keine konkrete Implementierung.
plugins {
alias(libs.plugins.kotlin.jvm)
}
// Erlaubt die Verwendung der kotlin.time API im gesamten Modul
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xopt-in=kotlin.time.ExperimentalTime")
}
}
dependencies {
// Stellt sicher, dass alle Versionen aus der zentralen BOM kommen.
implementation(platform(projects.platform.platformBom))
// Stellt gemeinsame Abhängigkeiten wie Logging bereit.
implementation(projects.platform.platformDependencies)
// Stellt Test-Abhängigkeiten bereit.
testImplementation(projects.platform.platformTesting)
}