Class TieredRuleCache

java.lang.Object
com.helix.core.cache.TieredRuleCache
All Implemented Interfaces:
AutoCloseable

public class TieredRuleCache extends Object implements AutoCloseable
Multi-tier rule cache supporting L1 (Strong Caffeine), L2 (SoftReference), L3 (WeakReference), and L4 (Distributed Redis) with promotion and cluster invalidation.
  • Constructor Details

    • TieredRuleCache

      public TieredRuleCache()
    • TieredRuleCache

      public TieredRuleCache(long l1MaxSize, long l1ExpireAfterWriteMinutes, TimeUnit unit)
    • TieredRuleCache

      public TieredRuleCache(long l1MaxSize, long l1ExpireAfterWriteMinutes, TimeUnit unit, DistributedRuleCache l4Cache, Function<byte[],CompiledRule> l4RuleLoader)
  • Method Details

    • put

      public void put(CacheKey key, CompiledRule rule)
    • hotSwap

      public void hotSwap(CacheKey key, CompiledRule newRule, byte[] bytecode)
      Atomically hot-swaps an existing cached compiled rule with an optimized version with zero downtime. Updates L1 Caffeine cache atomically, removes stale demoted references in L2/L3, and publishes updated bytecode to the L4 distributed tier if configured.
      Parameters:
      key - cache key identifying the rule
      newRule - newly compiled rule instance
      bytecode - optional raw class bytecode to persist in L4
    • hotSwap

      public void hotSwap(CacheKey key, CompiledRule newRule)
    • get

      public Optional<CompiledRule> get(CacheKey key)
    • putL2

      public void putL2(CacheKey key, CompiledRule rule)
    • putL3

      public void putL3(CacheKey key, CompiledRule rule)
    • invalidate

      public void invalidate(CacheKey key)
    • invalidateByName

      public void invalidateByName(String ruleName)
      Purges all cache entries matching the specified rule name across local L1, L2, and L3 tiers.
      Parameters:
      ruleName - name of the rule to evict
    • getL4Cache

      public DistributedRuleCache getL4Cache()
    • clear

      public void clear()
    • getStats

      public CacheStatsSnapshot getStats()
    • getCacheStatistics

      public CacheStatistics getCacheStatistics()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable