How oschina/j2cache works
Main Components Identification
The system should be represented with these key components:
a. Level 1 Cache (L1):
• Caffeine (default)
• Ehcache 2.x (alternative)
• Ehcache 3.x (alternative)
b. Level 2 Cache (L2):
• Redis (primary)
• Memcached (alternative)
c. Broadcast Mechanisms:
• Redis Pub/Sub
• JGroups
• RabbitMQ
• RocketMQ
Architecture Layers
a. API Layer:
• CacheChannel interface
• J2CacheBuilder
• Configuration management
b. Core Layer:
• Cache providers
• Serialization utilities
• Cluster policies
c. Integration Layer:
• Spring Boot starters
• Hibernate modules
• MyBatis support
• Session management
Design Elements
Use these visual elements:
a. Components:
• Rectangles for cache providers
• Hexagons for message brokers
b. Connections:
• Double lines for data synchronization
• Blue: L1 cache components
• Green: L2 cache components
• Orange: Broadcasting mechanisms
• Gray: Integration modules
Key Workflows
Primary flows:
a. Read Path:
Populate both cache levels
b. Write Path:
Broadcast invalidation message
c. Cache Synchronization:
Integration Points
Integration with:
• Spring Framework
• Hibernate (3.x, 4.x, 5.x)
• MyBatis
• Web Session Management
Configuration Components
Configuration sources:
• j2cache.properties
• caffeine.properties
• ehcache.xml/ehcache3.xml
• network.xml
Deployment View
Multiple application nodes:
• Application instances with L1 cache
• Shared L2 cache (Redis/Memcached)
• Message broker for synchronization
• Database backend
Configuration management
• Cache levels
• Data flow directions
• Synchronization mechanisms
• Integration points
• Configuration elements
Keep the abstraction level high enough to show the overall architecture while including sufficient detail to understand the caching strategy and synchronization mechanisms.