Class ClaimingCacheOld<K,V>

java.lang.Object
org.aksw.commons.cache.plain.ClaimingCacheOld<K,V>
Type Parameters:
K -
V -

public class ClaimingCacheOld<K,V> extends Object
An extension of loading cache that allows for making explicit references to cached entries such that they won't be evicted. Uses 'smart' references. The cache: Upon load, the cache first checks whether for the key there is already a claimed reference. Upon load it references its own item, and releases this reference upon removal. Claiming: Claiming an item acquires an additional reference and adds that reference to the claimed map. When a claimed item is no longer referenced, the item is put back to cache.
Author:
raven
  • Field Details

    • cache

      protected com.google.common.cache.LoadingCache<K,Ref<V>> cache
    • claimed

      protected Map<K, Ref<Ref<V>>> claimed
  • Constructor Details

    • ClaimingCacheOld

      public ClaimingCacheOld(com.google.common.cache.CacheBuilder<Object,Object> cacheBuilder, Function<K,Ref<V>> cacheLoader, com.google.common.cache.RemovalListener<K,Ref<V>> removalListener)
  • Method Details

    • create

      public static <K,V> ClaimingCacheOld<K,V> create(com.google.common.cache.CacheBuilder<Object,Object> cacheBuilder, Function<K,Ref<V>> cacheLoader, com.google.common.cache.RemovalListener<K,Ref<V>> removalListener)
    • link

      public <V> Ref<V> link(Ref<? extends Ref<V>> refToRef)
    • claimUnsafe

      public Ref<V> claimUnsafe(K key)
    • claim

      public Ref<V> claim(K key) throws ExecutionException
      Claim a reference to the key's entry.
      Parameters:
      key -
      Returns:
      Throws:
      ExecutionException
    • claimIfPresent

      public Ref<V> claimIfPresent(K key)
      Cannot raise an ExecutionException because it does not trigger loading
    • invalidateAll

      public void invalidateAll()