Class CacheApi

java.lang.Object
io.github.xanthic.cache.core.CacheApi

public final class CacheApi
extends java.lang.Object
Primary API interaction point to build Cache instances.
See Also:
create(Consumer)
  • Method Summary

    Modifier and Type Method Description
    static <K,​ V> io.github.xanthic.cache.api.Cache<K,​V> create​(java.util.function.Consumer<CacheApiSpec<K,​V>> spec)
    Builds a generic Cache according to the desired specification.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static <K,​ V> io.github.xanthic.cache.api.Cache<K,​V> create​(java.util.function.Consumer<CacheApiSpec<K,​V>> spec)
      Builds a generic Cache according to the desired specification.
      Type Parameters:
      K - the type of keys that form the cache
      V - the type of values that are contained in the cache
      Parameters:
      spec - consumer in which the desired cache settings should be specified
      Returns:
      Cache
      Throws:
      io.github.xanthic.cache.api.exception.NoDefaultCacheImplementationException - if a provider is not specified and no default provider has been set
      io.github.xanthic.cache.api.exception.MisconfiguredCacheException - if the cache settings are invalid (e.g., negative max size or expiry time)
      See Also:
      ICacheSpec, CacheApiSettings