Class CacheFactory

java.lang.Object
org.apache.jena.atlas.lib.CacheFactory

public class CacheFactory extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <Key, Value>
    Cache<Key,Value>
    createCache(int maxSize)
    Create a cache which has space for up to a certain number of objects.
    static <Key, Value>
    Cache<Key,Value>
    createCache(int maxSize, double initialCapacityFactor)
     
    static <Key, Value>
    Cache<Key,Value>
    createCache(int maxSize, BiConsumer<Key,Value> dropHandler)
    Create a cache which has space for up to a certain number of objects.
    static <Key, Value>
    Cache<Key,Value>
    createCache(int maxSize, BiConsumer<Key,Value> dropHandler, double initialCapacityFactor)
    Create a cache which has space for up to a certain number of objects and with a configurable initial capacity.
    static <Obj> CacheSet<Obj>
    createCacheSet(int size)
    Create set-cache, rather than a map-cache.
    static <Key, Value>
    Cache<Key,Value>
    Create a null cache.
    static <Key, Value>
    Cache<Key,Value>
    One slot cache
    static <Key, Value>
    Cache<Key,Value>
    Create a lightweight cache (e.g. slot replacement).
    static <Obj> CacheSet<Obj>
    createSync(CacheSet<Obj> cache)
    Add a synchronization wrapper to an existing set-cache
    static <Key, Value>
    Cache<Key,Value>
    wrap(com.github.benmanes.caffeine.cache.Cache<Key,Value> caffeine)
    Wrap an existing Caffeine cache

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CacheFactory

      public CacheFactory()
  • Method Details

    • createCache

      public static <Key, Value> Cache<Key,Value> createCache(int maxSize)
      Create a cache which has space for up to a certain number of objects. This is an LRU cache, or similar. The cache returns null for a cache miss. The cache is thread-safe for single operations.
    • createCache

      public static <Key, Value> Cache<Key,Value> createCache(int maxSize, BiConsumer<Key,Value> dropHandler)
      Create a cache which has space for up to a certain number of objects. This is an LRU cache, or similar. The cache returns null for a cache miss. The cache is thread-safe for single operations.
    • createCache

      public static <Key, Value> Cache<Key,Value> createCache(int maxSize, double initialCapacityFactor)
    • createCache

      public static <Key, Value> Cache<Key,Value> createCache(int maxSize, BiConsumer<Key,Value> dropHandler, double initialCapacityFactor)
      Create a cache which has space for up to a certain number of objects and with a configurable initial capacity.
    • wrap

      public static <Key, Value> Cache<Key,Value> wrap(com.github.benmanes.caffeine.cache.Cache<Key,Value> caffeine)
      Wrap an existing Caffeine cache
    • createNullCache

      public static <Key, Value> Cache<Key,Value> createNullCache()
      Create a null cache.

      This cache never retains a value and always evaluates in Cache.getOrFill(Key, java.util.concurrent.Callable<Value>).

      This cache is thread-safe.

    • createSimpleCache

      public static <Key, Value> Cache<Key,Value> createSimpleCache(int size)
      Create a lightweight cache (e.g. slot replacement). This cache is not thread-safe.
    • createOneSlotCache

      public static <Key, Value> Cache<Key,Value> createOneSlotCache()
      One slot cache
    • createCacheSet

      public static <Obj> CacheSet<Obj> createCacheSet(int size)
      Create set-cache, rather than a map-cache. The cache is thread-safe for single operations.
      See Also:
    • createSync

      public static <Obj> CacheSet<Obj> createSync(CacheSet<Obj> cache)
      Add a synchronization wrapper to an existing set-cache