Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
3807ea7
Initial plan
Copilot Feb 11, 2026
a5b6af4
Add comprehensive caching implementation analysis document
Copilot Feb 11, 2026
52c1250
Add caching analysis quick reference summary
Copilot Feb 11, 2026
12108ae
Convert ASCII diagrams to Mermaid format
Copilot Feb 11, 2026
7a304d1
Add client-side config and JDBC driver relay approaches with honest e…
Copilot Feb 11, 2026
97af9fe
Revise recommendations based on ORM reality and data-in-memory insight
Copilot Feb 11, 2026
e37737a
Add multi-datasource awareness to server-side cache configuration
Copilot Feb 11, 2026
42a8e92
Add hot-reload support to server-side cache configuration (zero downt…
Copilot Feb 12, 2026
bd2e798
Simplify to client-side ojp.properties configuration (aligned with ex…
Copilot Feb 12, 2026
55f1fd1
Add clear Final Design Decision section at top of all documents
Copilot Feb 12, 2026
3596936
Make JDBC driver relay cache distribution optional via ojp.cache.dist…
Copilot Feb 12, 2026
59e6d6f
Add detailed phased implementation plan for local caching only (exclu…
Copilot Mar 24, 2026
e260799
Restructure implementation plan into 14 Copilot session-sized phases
Copilot Mar 24, 2026
7917486
Phase 1: Implement core caching data structures (QueryCacheKey, Cache…
Copilot Mar 24, 2026
b6eadea
Add ADR-001: Caching library selection (Caffeine chosen over 6 altern…
Copilot Mar 24, 2026
201984a
Phase 2: Implement configuration parsing (CacheConfigurationParser, C…
Copilot Mar 24, 2026
dfb3cde
Move and shorten ADR to documents/ADRs/adr-008-use-caffeine-for-cachi…
Copilot Mar 24, 2026
49d08bb
Phase 3: Implement cache storage with Caffeine (QueryResultCache, Cac…
Copilot Mar 24, 2026
0585d92
Phase 4: Implement protocol updates for cache configuration transmission
Copilot Mar 24, 2026
e17d0bb
Phase 5: Implement session integration for cache configuration
Copilot Mar 24, 2026
951f854
Merge branch 'main' into copilot/analyze-caching-implementation
rrobetti Mar 24, 2026
7b35d57
Phase 6: Implement query execution cache lookup
Copilot Mar 24, 2026
0f34dfc
Phase 7: Implement query execution cache storage
Copilot Mar 24, 2026
2ce852b
Phase 8: Implement SQL table extraction using JSqlParser
Copilot Mar 24, 2026
37a998f
Phase 9: Implement write invalidation for cache
Copilot Mar 24, 2026
6de6467
Refactor: Move cache config to properties and remove distribute field
Copilot Mar 25, 2026
c5b2dc0
Add refactoring summary document
Copilot Mar 25, 2026
22409ba
Merge main and adapt cache logic to refactored action classes
Copilot Mar 25, 2026
75dffce
Add documentation for action-based architecture refactoring
Copilot Mar 25, 2026
e3b3284
Phase 10: Add OpenTelemetry-based cache metrics implementation
Copilot Mar 25, 2026
ebeadae
Fix compilation error: Use correct ParameterValue proto type
Copilot Mar 25, 2026
b89623a
Phase 11: Production hardening - validation, security, documentation
Copilot Mar 25, 2026
9c55c75
Add Phase 11 implementation summary
Copilot Mar 25, 2026
0cc0bbb
Phase 12: Add metrics and concurrency tests (2 new test classes)
Copilot Mar 25, 2026
f95fd87
Phase 12 Complete: Add performance benchmarks and implementation summary
Copilot Mar 25, 2026
8ac3492
Phase 13 Complete: Add E2E tests, workload simulations, and implement…
Copilot Mar 25, 2026
1fd0459
Phase 14 Complete: Production deployment documentation and procedures
Copilot Mar 26, 2026
3974730
Fix compilation errors: CircuitBreaker constructor, Session access, P…
Copilot Mar 26, 2026
d6d89e5
Fix StatementServiceImpl constructor call - remove extra CircuitBreak…
Copilot Mar 26, 2026
21bacc7
Fix all remaining compilation errors: Session import, proto types, Ca…
Copilot Mar 26, 2026
1e380f6
Fix final compilation errors: method signatures, access patterns, OpQ…
Copilot Mar 26, 2026
4f3472e
Fix final 4 compilation errors: ActionContext parameter, OpQueryResul…
Copilot Mar 26, 2026
4e972f8
Fix final 3 compilation errors: method signature consistency and prot…
Copilot Mar 26, 2026
0d40f80
Fix test files to use correct constructor signatures
Copilot Mar 26, 2026
f5356f1
Fix CacheEndToEndTest.java with correct constructor signatures
Copilot Mar 26, 2026
947cb25
Fix compilation errors in 8 cache test files
Copilot Mar 26, 2026
22f6fc2
Fix compilation errors in cache test files
Copilot Mar 26, 2026
f375aca
Fix integration test failures: CacheConcurrencyTest and CacheConfigur…
Copilot Mar 26, 2026
724a56c
Fix CacheConfigurationParserTest.testParseMissingPattern - check for …
Copilot Mar 26, 2026
4c97556
Fix all 18 failing cache tests + QueryResultCache bug (oversized resu…
Copilot Mar 26, 2026
12d5e71
Fix QueryResultCache.invalidateAll() - let removal listeners handle s…
Copilot Mar 26, 2026
4932c47
Fix QueryResultCache.invalidateAll() - add cleanUp() to ensure synchr…
Copilot Mar 26, 2026
e7fbd55
Fix QueryResultCache - add cleanUp() calls to all invalidation methods
Copilot Mar 26, 2026
9f3e6b6
Fix QueryResultCache.put() - add cleanUp() to ensure removal listener…
Copilot Mar 26, 2026
f5bca34
Fix QueryResultCache.put() - call cleanUp() BEFORE incrementing size,…
Copilot Mar 26, 2026
b4e5c1b
Add extensive debug logging to QueryResultCache for size tracking inv…
Copilot Mar 26, 2026
fc69428
Revert debug logging - remove verbose logs from QueryResultCache
Copilot Mar 26, 2026
0d3eacb
Fix QueryResultCache - call cleanUp() before AND after invalidateAll()
Copilot Mar 27, 2026
de1628b
Fix test QueryResultCacheTest.testSizeTracking.
rrobetti Mar 27, 2026
a66adc6
Fix test QueryResultCacheTest.testInvalidateAll.
rrobetti Mar 27, 2026
c5d1692
Reorganize documentation: remove phase summaries, move caching docs t…
Copilot Mar 27, 2026
582d02f
Address code review comments: add private constructor, handle default…
Copilot Mar 27, 2026
96abd4a
Document multi-server cache invalidation limitation clearly across al…
Copilot Mar 27, 2026
9b6a9df
Merge latest main branch (v0.4.1-beta)
Copilot Apr 5, 2026
1adab36
Refactor cache code: extract helper classes, fix code smells, update …
Copilot Apr 5, 2026
1ba19eb
Cache proto objects directly, use proto size, centralize invalidation…
Copilot Apr 5, 2026
934f3eb
Fix compilation errors after proto caching refactoring
Copilot Apr 5, 2026
8ac5f3e
Fix all compilation errors and address code review feedback
Copilot Apr 6, 2026
93130d6
Fix compilation error: change Property to PropertyEntry in QueryCache…
Copilot Apr 6, 2026
61191a9
Fix compilation errors: use cacheConfig.getDatasourceName() and fully…
Copilot Apr 6, 2026
81e41b8
Fix remaining 5 test files to use proto-based CachedQueryResult const…
Copilot Apr 6, 2026
8a83959
Fix CachedQueryResult.getAffectedTables() to return defensive copy
Copilot Apr 6, 2026
947adec
Fix CachedQueryResult.getAffectedTables() to always return new instance
Copilot Apr 6, 2026
9a17a06
Remove server-side cache configuration (CacheConfigurationParser, Cac…
Copilot Apr 7, 2026
d8bc1dc
Remove unused CachedResultHandler class - ExecuteQueryAction builds O…
Copilot Apr 7, 2026
2d315e0
Remove UNION SELECT validation from CacheSecurityValidator - allow le…
Copilot Apr 7, 2026
eb87ac8
Fix Sonar issues from PR #343 review comments in test files
Copilot Apr 7, 2026
a374502
Fix Sonar: remove unnecessary throws Exception, add assertion to disa…
Copilot Apr 7, 2026
f39948b
Merge pull request #411 from Open-J-Proxy/copilot/review-unanswered-c…
rrobetti Apr 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions documents/ADRs/adr-008-use-caffeine-for-caching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ADR 008: Use Caffeine for Query Result Caching

In the context of the OJP query result caching implementation,
facing the need to cache query results with TTL-based expiration, bounded size, thread-safe concurrent access, and high performance,

we decided for using **Caffeine** as the caching library
and neglected Google Guava Cache, EhCache 3, Infinispan, Redis, custom ConcurrentHashMap, and Apache Commons JCS,

to achieve near-optimal hit rates (within 1% of theoretical maximum), sub-5ms P95 latency, and production-proven reliability,
accepting the dependency on Caffeine (~900KB JAR),

because Caffeine delivers 3x faster performance than alternatives (280M vs 93M reads/sec vs Guava), uses Window TinyLFU eviction for optimal hit rates, provides built-in Micrometer metrics integration (aligning with OJP's existing observability), and is battle-tested in Spring Boot, Hibernate, Cassandra, and Elasticsearch.

## Alternatives Considered

### 1. Google Guava Cache
**Rejected**: 3x slower than Caffeine; Google officially recommends Caffeine; in maintenance mode since 2014

### 2. EhCache 3
**Rejected**: Over-engineered for local caching (5MB+ with dependencies); complex XML configuration; designed for distributed caching

### 3. Infinispan
**Rejected**: Massive overkill (10MB+ data grid) for local caching use case; adds unnecessary complexity

### 4. Redis
**Rejected**: External dependency adds network latency (1-5ms); requires separate infrastructure; operational complexity

### 5. Custom ConcurrentHashMap
**Rejected**: Weeks of development to implement TTL, eviction, thread-safe stats; would be suboptimal compared to Caffeine's proven algorithms

### 6. Apache Commons JCS
**Rejected**: Abandoned project (last release 2017); 5-10x slower than Caffeine in benchmarks

## Implementation

Phase 3 wraps Caffeine with `QueryResultCache` class:
- Configuration via `ojp.properties` (maxSize, defaultTtl)
- Automatic Micrometer metrics integration (Phase 10)
- Thread-safe operations with minimal custom code

| Status | APPROVED |
|-------------|-----------------|
| Proposer(s) | Rogerio Robetti |
| Proposal date | 24/03/2026 |
| Approver(s) | Rogerio Robetti |
| Approval date | 24/03/2026 |
Loading
Loading