Class ValueObjectCache<T>

java.lang.Object
org.naviqore.utils.cache.ValueObjectCache<T>
Type Parameters:
T - the type of the value objects to be cached

public class ValueObjectCache<T> extends Object
A generic cache for immutable value objects.

The cache stores value objects of type T, ensuring that only one instance of each unique value is retained in memory.

  • Constructor Details

    • ValueObjectCache

      public ValueObjectCache()
  • Method Details

    • getOrAdd

      public T getOrAdd(T value)
      Retrieves the value from the cache or adds it if it does not exist.
      Parameters:
      value - the value to be cached
      Returns:
      the cached value
    • clear

      public void clear()
      Clear the cache.