Class L4RedisRuleCache

java.lang.Object
com.helix.core.cache.l4.L4RedisRuleCache
All Implemented Interfaces:
DistributedRuleCache, AutoCloseable

public class L4RedisRuleCache extends Object implements DistributedRuleCache
Enterprise L4 Distributed Rule Cache backed by Redis. Uses atomic Lua scripts for fetch-or-lock stampede protection and Pub/Sub invalidation. Degrades gracefully to in-memory fallback when Redis is unreachable.
  • Constructor Details

    • L4RedisRuleCache

      public L4RedisRuleCache()
    • L4RedisRuleCache

      public L4RedisRuleCache(L4RedisConfig config)
    • L4RedisRuleCache

      public L4RedisRuleCache(String host, int port, int timeoutMs, boolean allowFallback)
    • L4RedisRuleCache

      public L4RedisRuleCache(String host, int port, int timeoutMs, int maxTotalPool, int ttlSeconds, boolean allowFallback)
  • Method Details

    • getBytecode

      public Optional<byte[]> getBytecode(String ruleHash)
      Description copied from interface: DistributedRuleCache
      Retrieves compiled bytecode by its deterministic rule hash.
      Specified by:
      getBytecode in interface DistributedRuleCache
      Parameters:
      ruleHash - SHA-256 rule hash
      Returns:
      Optional containing raw class bytecode if present in the distributed tier
    • putBytecode

      public void putBytecode(String ruleHash, String ruleName, String version, byte[] bytecode)
      Description copied from interface: DistributedRuleCache
      Stores compiled bytecode with rule metadata in the distributed cache tier.
      Specified by:
      putBytecode in interface DistributedRuleCache
      Parameters:
      ruleHash - SHA-256 rule hash
      ruleName - name of the rule
      version - rule version
      bytecode - compiled JVM class bytes
    • invalidate

      public void invalidate(String ruleHash)
      Description copied from interface: DistributedRuleCache
      Evicts a single rule from the distributed cache.
      Specified by:
      invalidate in interface DistributedRuleCache
      Parameters:
      ruleHash - SHA-256 rule hash
    • invalidateAll

      public void invalidateAll()
      Description copied from interface: DistributedRuleCache
      Evicts all cached rules across the distributed cluster.
      Specified by:
      invalidateAll in interface DistributedRuleCache
    • getRuleData

      public Optional<SerializedRuleData> getRuleData(String ruleHash)
    • getHitCount

      public long getHitCount()
      Description copied from interface: DistributedRuleCache
      Returns the total number of cache hits on this distributed tier.
      Specified by:
      getHitCount in interface DistributedRuleCache
      Returns:
      cumulative hit count
    • getMissCount

      public long getMissCount()
      Description copied from interface: DistributedRuleCache
      Returns the total number of cache misses on this distributed tier.
      Specified by:
      getMissCount in interface DistributedRuleCache
      Returns:
      cumulative miss count
    • isFallbackActive

      public boolean isFallbackActive()
    • getHost

      public String getHost()
    • getPort

      public int getPort()
    • getTimeoutMs

      public int getTimeoutMs()
    • getTtlSeconds

      public int getTtlSeconds()
    • isAllowFallback

      public boolean isAllowFallback()
    • close

      public void close()
      Description copied from interface: DistributedRuleCache
      Closes connections or client pools associated with this distributed cache tier.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface DistributedRuleCache