Class RuleCache
java.lang.Object
com.beassolution.rule.engine.cache.RuleCache
Cache for compiled rule expressions.
This class provides a thread-safe cache for storing compiled MVEL expressions that represent rules in the Beas Rule Engine. The cache improves performance by avoiding re-compilation of rules on each execution.
Key features include:
- Thread-safe operations using ConcurrentHashMap
- Compiled MVEL expressions storage
- Bulk operations support
- Cache management operations
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Beas Solution Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all compiled rule expressions from the cache.boolean
Checks if a rule expression is cached.Retrieves a compiled rule expression from the cache.getAll()
Retrieves all cached rule expressions.void
put
(String key, Serializable instance) Stores a compiled rule expression in the cache.void
putAll
(Map<String, Serializable> map) Stores multiple compiled rule expressions in the cache.void
Removes a compiled rule expression from the cache.
-
Constructor Details
-
RuleCache
public RuleCache()
-
-
Method Details
-
put
Stores a compiled rule expression in the cache.- Parameters:
key
- The rule nameinstance
- The compiled MVEL expression
-
putAll
Stores multiple compiled rule expressions in the cache.- Parameters:
map
- Map containing rule names and compiled expressions
-
get
Retrieves a compiled rule expression from the cache.- Parameters:
key
- The rule name- Returns:
- Optional containing the compiled expression if found
-
remove
Removes a compiled rule expression from the cache.- Parameters:
key
- The rule name to remove
-
clear
public void clear()Clears all compiled rule expressions from the cache.This method removes all entries from the cache, typically used during cache synchronization or system reset.
-
getAll
Retrieves all cached rule expressions.- Returns:
- Immutable copy of all cached expressions
-
contains
Checks if a rule expression is cached.- Parameters:
key
- The rule name to check- Returns:
- true if the rule is cached, false otherwise
-