Main Answer: Multi-level caching using Ehcache for local JVM storage and Redis for shared cluster caches optimizes database access speeds in Liferay DXP.
Audience: Cluster administrators, database architects, and system engineering leads.
Applicable Use Cases: Caching portal database records, synchronizing cache states across nodes, and tuning cache eviction algorithms.
| Cache Level | Technology Used | Best Use Case |
|---|---|---|
| Level 1 (Local) | Ehcache (JVM Memory) | Fast retrieval of static portal settings, layouts, and page schemas |
| Level 2 (Shared) | Redis Cluster (External) | Synchronizing session tables and content listings across replicas |
Tuning Ehcache XML Parameters
Liferay uses Ehcache for local caching. Tune liferay-multi-vm-clustered.xml. Adjust max elements
in memory and set time-to-idle values to cache database results locally, reducing SQL query latency.
How Do You Connect Liferay DXP to a Redis Cache Cluster?
Direct Answer: Configure Redis properties in portal settings, specifying cluster endpoint URLs, security passwords, and connection timeout rules.
Configure Liferay's Redis integration in System Settings. Specify host addresses, ports, and connection pools. Redis shares cache items across portal instances, ensuring users retain session details when migrating across servers.
# Redis clustered environment configuration
redis.hosts=10.0.5.10:6379,10.0.5.11:6379
redis.timeout=2000
redis.maxTotal=100
For additional optimization strategies, visit our detailed Liferay DXP developer blog listing. For configuration specifications, consult the official Liferay Documentation portal.
Redis acts as a shared cache layer. When a portal node updates a record, it invalidates caches across nodes, keeping data uniform.
Frequently Asked Questions
Is Redis required for portal clustering?
Yes. Distributed portals must share session states and cache structures. Redis acts as the centralized cache provider for cluster nodes.
How do we flush Ehcache manually?
Go to Control Panel > Server Administration > Actions, and click 'Clear database cache' or 'Clear content cached across the cluster'.