Class VariableCache

java.lang.Object
com.beassolution.rule.engine.cache.VariableCache

@Component public final class VariableCache extends Object
Cache for rule variables and context.

This class provides a thread-safe cache for storing variables and context data that are used during rule execution in the Beas Rule Engine. The cache stores rule-specific variables that are made available during MVEL expression evaluation.

Key features include:

  • Thread-safe operations using ConcurrentHashMap
  • Rule-specific variable storage
  • Bulk operations support
  • Cache management operations
Since:
1.0
Version:
1.0
Author:
Beas Solution Team
  • Constructor Details

    • VariableCache

      public VariableCache()
  • Method Details

    • put

      public void put(String key, Object instance)
      Stores variables for a rule in the cache.
      Parameters:
      key - The rule name
      instance - The variables map for the rule
    • putAll

      public void putAll(Map<String,Object> map)
      Stores multiple rule variable sets in the cache.
      Parameters:
      map - Map containing rule names and variable sets
    • get

      public Optional<Object> get(String key)
      Retrieves variables for a rule from the cache.
      Parameters:
      key - The rule name
      Returns:
      Optional containing the variables if found
    • remove

      public void remove(String key)
      Removes variables for a rule from the cache.
      Parameters:
      key - The rule name to remove
    • clear

      public void clear()
      Clears all rule variables from the cache.

      This method removes all entries from the cache, typically used during cache synchronization or system reset.

    • getAll

      public Map<String,Object> getAll()
      Retrieves all cached rule variables.
      Returns:
      Immutable copy of all cached variables
    • contains

      public boolean contains(String key)
      Checks if variables for a rule are cached.
      Parameters:
      key - The rule name to check
      Returns:
      true if variables are cached, false otherwise
    • toString

      public String toString()
      Returns a string representation of the cache.
      Overrides:
      toString in class Object
      Returns:
      String containing cache statistics