Class CacheWrapper<Key,T>

java.lang.Object
org.apache.jena.atlas.lib.cache.CacheWrapper<Key,T>
All Implemented Interfaces:
Cache<Key,T>

public class CacheWrapper<Key,T> extends Object implements Cache<Key,T>
  • Constructor Details

    • CacheWrapper

      public CacheWrapper(Cache<Key,T> cache)
  • Method Details

    • clear

      public void clear()
      Specified by:
      clear in interface Cache<Key,T>
    • containsKey

      public boolean containsKey(Key key)
      Description copied from interface: Cache
      Does the cache contain the key?
      Specified by:
      containsKey in interface Cache<Key,T>
      Parameters:
      key - The key to find. The key must not be null.
      Returns:
      True, if the cache contains the key, otherwise false.
    • getIfPresent

      public T getIfPresent(Key key)
      Description copied from interface: Cache
      Get from cache - or return null.
      Specified by:
      getIfPresent in interface Cache<Key,T>
      Parameters:
      key - The key for which the value is requested. The key must not be null.
      Returns:
      If the cache contains an entry for the given key, the value is returned, otherwise null.
    • getOrFill

      public T getOrFill(Key key, Callable<T> callable)
      Description copied from interface: Cache
      Get from cache; if not present, call the Callable to try to fill the cache. This operation should be atomic. The 'key' and 'callcable' must not be null.
      Specified by:
      getOrFill in interface Cache<Key,T>
    • get

      public T get(Key key, Function<Key,T> fucntion)
      Description copied from interface: Cache
      Get from cache; if not present, call the Function to fill the cache slot. This operation should be atomic.
      Specified by:
      get in interface Cache<Key,T>
      Parameters:
      key - The key, for which the value should be returned or calculated. The key must not be null.
      fucntion - If the cache does not contain the key, the callable is called to calculate a value. If the callable returns null, the key is not associated with hat value, as nulls are not accepted as values. The callable must not be null.
      Returns:
      Returns either the existing value or the calculated value. If callable is called and returns null, then null is returned.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Cache<Key,T>
    • keys

      public Iterator<Key> keys()
      Description copied from interface: Cache
      Iterate over all keys. Iterating over the keys requires the caller be thread-safe.
      Specified by:
      keys in interface Cache<Key,T>
    • put

      public void put(Key key, T thing)
      Description copied from interface: Cache
      Insert into the cache
      Specified by:
      put in interface Cache<Key,T>
      Parameters:
      key - The key for the 'thing' to store. The key must not be null.
      thing - If 'thing' is null, it will not be used as value, instead any existing entry with the same key will be removed.
    • remove

      public void remove(Key key)
      Description copied from interface: Cache
      Remove from cache - return true if key referenced an entry
      Specified by:
      remove in interface Cache<Key,T>
      Parameters:
      key - The key, which shall be removed along with its value. The key must not be null.
    • size

      public long size()
      Description copied from interface: Cache
      Current size of cache
      Specified by:
      size in interface Cache<Key,T>