Cache with Oracle Database#994
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Oracle-backed Micronaut SyncCache implementation with schema bootstrap, scheduler-driven cleanup, and expanded testing/docs to support Oracle database persistence.
Changes:
- Introduces new
cache-oraclemodule with Oracle schema DDL/PLSQL, cache implementation, repositories, and bean factory wiring. - Adds Oracle-specific documentation and links it into the guide TOC.
- Expands automated testing via Testcontainers-based Oracle integration tests and shared sync TCK coverage.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/docs/guide/toc.yml | Adds Oracle docs entry to the guide TOC. |
| src/main/docs/guide/oracle.adoc | New documentation for Oracle cache usage and configuration. |
| settings.gradle | Includes new cache-oracle module; imports Micronaut Data/SQL BOM catalogs. |
| gradle/libs.versions.toml | Adds Oracle JDBC + Testcontainers Oracle and Micronaut Data/SQL version/bom entries. |
| cache-oracle/build.gradle | Configures the new module dependencies and Testcontainers-related test settings. |
| cache-oracle/src/main/resources/db/oracle-cache.sql | Defines Oracle tables, indexes, and stored procedures for cache persistence, cleanup, scheduling, and blocking puts. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/OracleCacheFactory.java | Wires OracleSyncCache + shared OracleKeySerializer as Micronaut beans. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/OracleSyncCache.java | Implements Oracle-backed SyncCache operations, blocking/non-blocking writes, cleanup, and async stats updates. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/configuration/OracleCacheConfiguration.java | Adds Oracle-specific per-cache configuration (blocking, cleanup interval/batch, lock timeout). |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/schema/OracleCacheSchemaInitializer.java | Bootstraps schema and upserts per-cache config + registers cleanup jobs at startup. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/serialization/OracleKeySerializer.java | Canonicalizes keys to stable JSON payload + SHA-256 hash. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/serialization/OracleCacheKey.java | Holds key hash + key payload bytes (value object). |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/persistence/OracleCacheEntryRepository.java | Micronaut Data repository for entries + stored procedure binding. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/persistence/OracleCacheStatsRepository.java | Micronaut Data repository for stats updates via stored procedure. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/persistence/CacheEntryEntity.java | Entity mapping for MN_CACHE_ENTRY. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/persistence/CacheEntryId.java | Composite ID mapping for cache entries. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/persistence/CacheStatsEntity.java | Entity mapping for MN_CACHE_STATS. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/persistence/CacheConfigEntity.java | Entity mapping for MN_CACHE_CONFIG. |
| cache-oracle/src/main/java/io/micronaut/cache/oracle/package-info.java | Package-level Javadoc for the new module. |
| cache-oracle/src/test/resources/oracle-init/grant-cleanup-job-privileges.sql | Test-only SQL script to grant scheduler permissions to the test user. |
| cache-oracle/src/test/resources/logback.xml | Test logging configuration for the new module. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleTestSupport.groovy | Testcontainers Oracle bootstrapping + schema init + privilege grants helper. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleIntegrationSupport.groovy | Shared base for Oracle integration tests. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleKeySerializerTest.groovy | Unit tests for canonical cache key serialization. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleSyncCacheTest.groovy | Unit tests for core OracleSyncCache semantics and edge cases. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleSyncCacheIntegrationTest.groovy | Integration tests exercising real Oracle persistence and async stats. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleCleanupIntegrationTest.groovy | Integration tests verifying cleanup behavior including timezone handling and limits. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleCleanupScheduleIntegrationTest.groovy | Integration test verifying Oracle Scheduler-based cleanup job registration and execution. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleCacheRepositoryTest.groovy | Integration tests covering repository-level persistence/invalidation behaviors. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/OracleCacheConfigurationTest.groovy | Unit tests validating property binding + validation for Oracle cache configuration. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/schema/OracleCacheSchemaInitializerIntegrationTest.groovy | Integration tests validating schema init, procedures, and job registration. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/tck/OracleTckSupport.groovy | Shared TCK support context for Oracle-backed sync cache. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/tck/OracleSyncCacheSpec.groovy | Sync cache TCK spec for non-blocking mode. |
| cache-oracle/src/test/groovy/io/micronaut/cache/oracle/tck/OracleBlockingSyncCacheSpec.groovy | Sync cache TCK spec for blocking mode. |
| cache-core/src/main/java/io/micronaut/cache/interceptor/ParametersKey.java | Adds getParameters() accessor to support key serialization. |
|
Are you using OSON for serializing JSON? |
@ericsedlar Answering here as I do not seem to have the option to answer on thread. I am using Micronaut's JsonMapper, can switch to OSON if necessary. |
|
I think we should also have an OSON option
|
|
We have OSON support in https://github.com/micronaut-projects/micronaut-serialization/tree/3.0.x/serde-oracle-jdbc-json
If you are using Micronaut Data with JSON columns it is used automatically
Graeme
|
|
@radovanradic @alvarosanchez |
|
@ericsedlar @graemerocher |
alvarosanchez
left a comment
There was a problem hiding this comment.
This is overall looking in the right direction, few minor changes requested.
The only thing I'm wondering is: how well is this design prepared to support other databases in the future?
| import io.micronaut.core.annotation.AnnotationUtil; | ||
| import io.micronaut.context.env.Environment; | ||
| import io.micronaut.inject.BeanDefinition; | ||
| import org.flywaydb.core.Flyway; |
There was a problem hiding this comment.
do we want a hard dependency on Flyway for this?
There was a problem hiding this comment.
Made optional. Now there is a default migrator and a Flyway one, which the user can decide to toggle by adding flyway dep. Documentation edited.
|
@copilot resolve the merge conflicts in this pull request |
Adds a new Oracle-backed Micronaut cache implementation with database persistence, scheduler-driven cleanup, and schema bootstrap support:
Key implementation points
Verification
NOTE: this is a subsequent iteration of another closed PR. This one was re-created with squashed history and correct commit author attribution (previous one was using a placeholder git config).