Class InstanceCache

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

@Component public final class InstanceCache extends Object
Cache for helper class instances.

This class provides a thread-safe cache for storing instantiated helper class objects. The cache improves performance by avoiding repeated instantiation of helper classes during rule execution.

Key features include:

  • Thread-safe operations using ConcurrentHashMap
  • Helper class instance storage
  • Bulk operations support
  • Cache management operations
Since:
1.0
Version:
1.0
Author:
Beas Solution Team
  • Constructor Details

    • InstanceCache

      public InstanceCache()
  • Method Details

    • put

      public void put(String key, Map<String,Object> instance)
      Stores helper instances in the cache.
      Parameters:
      key - The helper name
      instance - The map of class names to instantiated objects
    • putAll

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

      public Optional<Map<String,Object>> get(String key)
      Retrieves helper instances from the cache.
      Parameters:
      key - The helper name
      Returns:
      Optional containing the helper instances if found
    • remove

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

      public void clear()
      Clears all helper instances from the cache.

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

    • getAll

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

      public boolean contains(String key)
      Checks if helper instances are cached.
      Parameters:
      key - The helper name to check
      Returns:
      true if helper instances 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