Package com.helix.core.cache.l4
Class L4RedisRuleCache
java.lang.Object
com.helix.core.cache.l4.L4RedisRuleCache
- All Implemented Interfaces:
DistributedRuleCache,AutoCloseable
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 Summary
ConstructorsConstructorDescriptionL4RedisRuleCache(L4RedisConfig config) L4RedisRuleCache(String host, int port, int timeoutMs, boolean allowFallback) L4RedisRuleCache(String host, int port, int timeoutMs, int maxTotalPool, int ttlSeconds, boolean allowFallback) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes connections or client pools associated with this distributed cache tier.Optional<byte[]> getBytecode(String ruleHash) Retrieves compiled bytecode by its deterministic rule hash.longReturns the total number of cache hits on this distributed tier.getHost()longReturns the total number of cache misses on this distributed tier.intgetPort()getRuleData(String ruleHash) intintvoidinvalidate(String ruleHash) Evicts a single rule from the distributed cache.voidEvicts all cached rules across the distributed cluster.booleanbooleanvoidputBytecode(String ruleHash, String ruleName, String version, byte[] bytecode) Stores compiled bytecode with rule metadata in the distributed cache tier.
-
Constructor Details
-
L4RedisRuleCache
public L4RedisRuleCache() -
L4RedisRuleCache
-
L4RedisRuleCache
-
L4RedisRuleCache
public L4RedisRuleCache(String host, int port, int timeoutMs, int maxTotalPool, int ttlSeconds, boolean allowFallback)
-
-
Method Details
-
getBytecode
Description copied from interface:DistributedRuleCacheRetrieves compiled bytecode by its deterministic rule hash.- Specified by:
getBytecodein interfaceDistributedRuleCache- Parameters:
ruleHash- SHA-256 rule hash- Returns:
- Optional containing raw class bytecode if present in the distributed tier
-
putBytecode
Description copied from interface:DistributedRuleCacheStores compiled bytecode with rule metadata in the distributed cache tier.- Specified by:
putBytecodein interfaceDistributedRuleCache- Parameters:
ruleHash- SHA-256 rule hashruleName- name of the ruleversion- rule versionbytecode- compiled JVM class bytes
-
invalidate
Description copied from interface:DistributedRuleCacheEvicts a single rule from the distributed cache.- Specified by:
invalidatein interfaceDistributedRuleCache- Parameters:
ruleHash- SHA-256 rule hash
-
invalidateAll
public void invalidateAll()Description copied from interface:DistributedRuleCacheEvicts all cached rules across the distributed cluster.- Specified by:
invalidateAllin interfaceDistributedRuleCache
-
getRuleData
-
getHitCount
public long getHitCount()Description copied from interface:DistributedRuleCacheReturns the total number of cache hits on this distributed tier.- Specified by:
getHitCountin interfaceDistributedRuleCache- Returns:
- cumulative hit count
-
getMissCount
public long getMissCount()Description copied from interface:DistributedRuleCacheReturns the total number of cache misses on this distributed tier.- Specified by:
getMissCountin interfaceDistributedRuleCache- Returns:
- cumulative miss count
-
isFallbackActive
public boolean isFallbackActive() -
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:DistributedRuleCacheCloses connections or client pools associated with this distributed cache tier.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDistributedRuleCache
-