Interface CmsObjectCacheSpec


public interface CmsObjectCacheSpec
Object cache configuration for CMS platforms.

Defines Redis/Memcached object caching capabilities for CMS deployments. Object caching significantly improves performance by storing:

  • Database query results
  • Computed page fragments
  • Session data
  • Transient/temporary data

Supported Backends:

  • Redis - Recommended for most CMS platforms
  • Memcached - Alternative for simple key-value caching

Usage Example:

if (spec instanceof CmsObjectCacheSpec cacheSpec) {
    if (cacheSpec.isObjectCacheEnabled()) {
        String backend = cacheSpec.getCacheBackend();
        Map<String, String> env = cacheSpec.getCachePluginEnvironment();
    }
}

4.0 migration intent

This is a CMS compatibility/binding contract, not a CMS-only cache provisioning model. During the 4.0 migration, object, session, and page-cache needs are adapted to named typed requirements such as cache.object, cache.sessions, and cache.pages. The platform resolves the allowed provider/profile, endpoint binding, network placement, encryption, access policy, target capability, entitlement restriction, and applicable compliance controls.

CMS-specific environment/configuration mapping remains application-owned. New application plugins should request reusable cache capabilities directly; existing implementations remain supported through the 4.0 compatibility adapter until synthesis, integration, parameterized, and compliance regressions prove equivalent behavior.

Since:
3.1.0
See Also:
  • Method Details

    • getCacheBackend

      String getCacheBackend()
      Returns the cache backend type.

      Supported backends:

      • "redis" - Redis 7.x (recommended)
      • "memcached" - Memcached
      • "none" - No object caching
      Returns:
      cache backend type
    • isObjectCacheEnabled

      default boolean isObjectCacheEnabled()
      Returns whether object caching is enabled.

      null/blank getCacheBackend() counts as disabled, not enabled — a CmsSpec implementation that hasn't configured a backend yet (including third-party plugins, which won't have been through the same internal review as the built-in specs) should fail safe to "no cache," not silently report caching as active with a meaningless endpoint/port downstream.

      Returns:
      true if object caching is enabled
    • getCacheEndpoint

      String getCacheEndpoint()
      Returns the Redis/Memcached endpoint.

      For ElastiCache, this is the primary endpoint or configuration endpoint for cluster mode.

      Returns:
      cache server hostname
    • getCachePort

      int getCachePort()
      Returns the cache port.

      Default ports:

      • Redis: 6379
      • Memcached: 11211
      Returns:
      cache port number
    • getCacheDatabase

      default int getCacheDatabase()
      Returns the Redis database index.

      Redis supports multiple databases (0-15). Different CMS components can use different databases for isolation:

      • 0 - Object cache
      • 1 - Session storage
      • 2 - Page cache

      Not applicable for Memcached.

      Returns:
      Redis database index (default: 0)
    • getSessionDatabase

      default int getSessionDatabase()
      Returns the Redis database for session storage.
      Returns:
      Redis database index for sessions (default: 1)
    • getPageCacheDatabase

      default int getPageCacheDatabase()
      Returns the Redis database for page cache.
      Returns:
      Redis database index for page cache (default: 2)
    • getCachePluginEnvironment

      Map<String,String> getCachePluginEnvironment()
      Returns environment variables for cache plugin configuration.

      CMS-specific environment variables:

      WordPress (Redis Object Cache):

      • WP_REDIS_HOST - Redis hostname
      • WP_REDIS_PORT - Redis port
      • WP_REDIS_DATABASE - Database index
      • WP_REDIS_PASSWORD - Auth password (if required)

      Magento:

      • MAGENTO_CACHE_BACKEND_REDIS_SERVER - Redis hostname
      • MAGENTO_CACHE_BACKEND_REDIS_PORT - Redis port
      • MAGENTO_SESSION_BACKEND_REDIS_SERVER - Session Redis

      Drupal:

      • DRUPAL_REDIS_HOST - Redis hostname
      • DRUPAL_REDIS_PORT - Redis port
      Returns:
      map of environment variable key-value pairs
    • requiresAuth

      default boolean requiresAuth()
      Returns whether AUTH is required for Redis.

      Recommended for production environments. ElastiCache Redis can be configured with AUTH tokens.

      Returns:
      true if Redis AUTH is required (default: true in production)
    • getCachePasswordSecretArn

      String getCachePasswordSecretArn()
      Returns the Secrets Manager ARN for cache password.

      The secret should contain the Redis AUTH password or Memcached SASL credentials.

      Returns:
      Secrets Manager ARN, or null if no auth required
    • getCacheKeyPrefix

      default String getCacheKeyPrefix()
      Returns the cache key prefix for this CMS instance.

      Useful for multi-site deployments sharing a Redis instance. Each site should have a unique prefix to avoid key collisions.

      Returns:
      cache key prefix (default: application ID)
    • getDefaultTtlSeconds

      default int getDefaultTtlSeconds()
      Returns the default TTL for cached items in seconds.
      Returns:
      TTL in seconds (default: 3600 = 1 hour)
    • enableClusterMode

      default boolean enableClusterMode()
      Returns whether to enable Redis cluster mode.

      Cluster mode provides automatic sharding across multiple nodes for improved scalability and availability.

      Returns:
      true to enable cluster mode (default: false)
    • enableTls

      default boolean enableTls()
      Returns whether to enable TLS for cache connections.

      Recommended for production environments. ElastiCache supports in-transit encryption with TLS.

      Returns:
      true to enable TLS (default: true in production)
    • getConnectionTimeoutMs

      default int getConnectionTimeoutMs()
      Returns the connection timeout in milliseconds.
      Returns:
      connection timeout (default: 5000ms)
    • getReadTimeoutMs

      default int getReadTimeoutMs()
      Returns the read timeout in milliseconds.
      Returns:
      read timeout (default: 1000ms)
    • enablePersistentConnections

      default boolean enablePersistentConnections()
      Returns whether to enable persistent connections.

      Persistent connections reduce connection overhead but require proper connection pooling configuration.

      Returns:
      true to enable persistent connections (default: true)