Package com.helix.core.cache
Class TieredRuleCache
java.lang.Object
com.helix.core.cache.TieredRuleCache
- All Implemented Interfaces:
AutoCloseable
Multi-tier rule cache supporting L1 (Strong Caffeine), L2 (SoftReference), L3 (WeakReference),
and L4 (Distributed Redis) with promotion and cluster invalidation.
-
Constructor Summary
ConstructorsConstructorDescriptionTieredRuleCache(long l1MaxSize, long l1ExpireAfterWriteMinutes, TimeUnit unit) TieredRuleCache(long l1MaxSize, long l1ExpireAfterWriteMinutes, TimeUnit unit, DistributedRuleCache l4Cache, Function<byte[], CompiledRule> l4RuleLoader) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclose()getStats()voidhotSwap(CacheKey key, CompiledRule newRule) voidhotSwap(CacheKey key, CompiledRule newRule, byte[] bytecode) Atomically hot-swaps an existing cached compiled rule with an optimized version with zero downtime.voidinvalidate(CacheKey key) voidinvalidateByName(String ruleName) Purges all cache entries matching the specified rule name across local L1, L2, and L3 tiers.voidput(CacheKey key, CompiledRule rule) voidputL2(CacheKey key, CompiledRule rule) voidputL3(CacheKey key, CompiledRule rule)
-
Constructor Details
-
TieredRuleCache
public TieredRuleCache() -
TieredRuleCache
-
TieredRuleCache
public TieredRuleCache(long l1MaxSize, long l1ExpireAfterWriteMinutes, TimeUnit unit, DistributedRuleCache l4Cache, Function<byte[], CompiledRule> l4RuleLoader)
-
-
Method Details
-
put
-
hotSwap
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 rulenewRule- newly compiled rule instancebytecode- optional raw class bytecode to persist in L4
-
hotSwap
-
get
-
putL2
-
putL3
-
invalidate
-
invalidateByName
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
-
clear
public void clear() -
getStats
-
getCacheStatistics
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-