Cache Configuration Reference
The complete cache configuration is managed via the CacheConfig class, bound to the query.cache prefix in application.yml.
Full Configuration
query:
cache:
# Global toggle
enabled: true
# L1: In-memory cache (Caffeine)
l1:
enabled: true
max-entries: 1000
max-size-mb: 256
ttl: PT10M # 10 minutes
expire-after-access: PT5M # 5 minutes idle expiry
# L2: Distributed cache (Redis)
l2:
enabled: true
key-prefix: "query:cache:"
ttl: PT1H # 1 hour
max-entry-size-mb: 50
compression-threshold-kb: 100
compression-enabled: true
# Cache warming
warming:
enabled: true
cron-expression: "0 0 6 * * ?"
max-queries-per-run: 100
min-hit-count: 5
lookback-period: P7D
delay-between-queries: PT1S
# Cache invalidation
invalidation:
dependency-based-enabled: true
event-based-enabled: true
event-topic: "query-cache-invalidation"
auto-invalidate-patterns: []
batch-size: 100
# Metrics
metrics:
enabled: true
publish-interval: PT30S
per-tenant-metrics: true
per-query-type-metrics: trueConfiguration Properties Reference
Global
| Property | Type | Default | Description |
|---|---|---|---|
query.cache.enabled | boolean | true | Master toggle for all caching |
L1 (Caffeine)
| Property | Type | Default | Description |
|---|---|---|---|
query.cache.l1.enabled | boolean | true | Enable in-memory cache |
query.cache.l1.max-entries | int | 1000 | Max entries before size-based eviction |
query.cache.l1.max-size-mb | int | 256 | Max total cache size in megabytes |
query.cache.l1.ttl | Duration | PT10M | Time-to-live after write |
query.cache.l1.expire-after-access | Duration | PT5M | Idle expiration time |
L2 (Redis)
| Property | Type | Default | Description |
|---|---|---|---|
query.cache.l2.enabled | boolean | true | Enable Redis cache |
query.cache.l2.key-prefix | String | query:cache: | Redis key prefix for namespacing |
query.cache.l2.ttl | Duration | PT1H | Time-to-live in Redis |
query.cache.l2.max-entry-size-mb | int | 50 | Skip caching entries larger than this |
query.cache.l2.compression-threshold-kb | int | 100 | GZIP compress entries above this size |
query.cache.l2.compression-enabled | boolean | true | Enable GZIP compression |
Warming
| Property | Type | Default | Description |
|---|---|---|---|
query.cache.warming.enabled | boolean | true | Enable scheduled warming |
query.cache.warming.cron-expression | String | 0 0 6 * * ? | Cron schedule (daily at 6 AM) |
query.cache.warming.max-queries-per-run | int | 100 | Max queries to warm per cycle |
query.cache.warming.min-hit-count | int | 5 | Min hit count to qualify for warming |
query.cache.warming.lookback-period | Duration | P7D | Historical period for popularity analysis |
query.cache.warming.delay-between-queries | Duration | PT1S | Throttle delay between warming queries |
Invalidation
| Property | Type | Default | Description |
|---|---|---|---|
query.cache.invalidation.dependency-based-enabled | boolean | true | Track and invalidate by table dependency |
query.cache.invalidation.event-based-enabled | boolean | true | Listen for Kafka invalidation events |
query.cache.invalidation.event-topic | String | query-cache-invalidation | Kafka topic name |
query.cache.invalidation.batch-size | int | 100 | Batch size for bulk invalidation |
Metrics
| Property | Type | Default | Description |
|---|---|---|---|
query.cache.metrics.enabled | boolean | true | Enable detailed cache metrics |
query.cache.metrics.publish-interval | Duration | PT30S | Metrics publishing interval |
query.cache.metrics.per-tenant-metrics | boolean | true | Emit per-tenant cache metrics |
query.cache.metrics.per-query-type-metrics | boolean | true | Emit per-query-type metrics |
Environment-Specific Overrides
Development
query:
cache:
l1:
max-size-mb: 64
ttl: PT2M
l2:
ttl: PT15M
warming:
enabled: falseProduction
query:
cache:
l1:
max-size-mb: 512
max-entries: 5000
ttl: PT15M
l2:
ttl: PT2H
max-entry-size-mb: 100
warming:
max-queries-per-run: 500
min-hit-count: 10