Class LimitCache<K,V>

java.lang.Object
io.higson.runtime.helper.parser.LimitCache<K,V>
Type Parameters:
K -
V -

public class LimitCache<K,V> extends Object
This is a very fast cache that implements memoization of pure functions. There is no eviction or expiration at all, so it can only be used to handle pure functions, i.e. functions that always give the same output for the same input.

After reaching approximately [maxSize] elements the cache is closed and ignores new entries.

In steady state the get() method is free from thread contention.

  • Constructor Details

    • LimitCache

      public LimitCache(String name, int maxSize)
    • LimitCache

      public LimitCache(String name)
  • Method Details

    • put

      public void put(K key, V value)
    • get

      public V get(K key)
    • size

      public int size()
    • isOpen

      public boolean isOpen()
    • getName

      public String getName()
    • getMaxSize

      public int getMaxSize()
    • setMaxSize

      public void setMaxSize(int maxSize)
    • toString

      public String toString()
      Overrides:
      toString in class Object