Class FunctionCache

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

@Component public final class FunctionCache extends Object
Cache for function library code.

This class provides a thread-safe cache for storing MVEL function code from function libraries. The cache improves performance by avoiding repeated loading of function code during rule compilation.

Key features include:

  • Thread-safe operations using ConcurrentHashMap
  • MVEL function code storage
  • Bulk operations support
  • Cache management operations
Since:
1.0
Version:
1.0
Author:
Beas Solution Team
  • Constructor Details

    • FunctionCache

      public FunctionCache()
  • Method Details

    • put

      public void put(String key, String instance)
      Stores function code in the cache.
      Parameters:
      key - The function library name
      instance - The MVEL function code
    • putAll

      public void putAll(Map<String,String> map)
      Stores multiple function codes in the cache.
      Parameters:
      map - Map containing function library names and MVEL code
    • get

      public Optional<String> get(String key)
      Retrieves function code from the cache.
      Parameters:
      key - The function library name
      Returns:
      Optional containing the function code if found
    • remove

      public void remove(String key)
      Removes function code from the cache.
      Parameters:
      key - The function library name to remove
    • clear

      public void clear()
      Clears all function codes from the cache.

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

    • getAll

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

      public boolean contains(String key)
      Checks if function code is cached.
      Parameters:
      key - The function library name to check
      Returns:
      true if the function code is cached, false otherwise
    • toString

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