Class Cache.DiskCacheBuilder

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Cache build()
      Creates a Cache instance.
      Cache.DiskCacheBuilder dir​(java.nio.file.Path dir)
      Sets the directory to store cache files.
      Cache.EncryptedDiskCacheBuilder encrypted()
      Creates a new EncryptedDiskCacheBuilder instance which will create Cache that stores all cache files encrypted by provided keys.
      B maxItems​(int maxItems)
      The maximum number of cache entries.
      B requestFilter​(java.util.function.Predicate<java.net.http.HttpRequest> filter)
      Adds given predicate to predicated chain.
      B responseFilter​(java.util.function.Predicate<java.net.http.HttpResponse.ResponseInfo> filter)
      Adds given predicate to predicated chain.
      B size​(long size)
      The amount of bytes allowed to be stored.
      • Methods inherited from class java.lang.Object

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

      • dir

        public Cache.DiskCacheBuilder dir​(java.nio.file.Path dir)
        Sets the directory to store cache files.
        Parameters:
        dir - The directory to store cache files.
        Returns:
        builder itself.
      • encrypted

        public Cache.EncryptedDiskCacheBuilder encrypted()
        Creates a new EncryptedDiskCacheBuilder instance which will create Cache that stores all cache files encrypted by provided keys.
        Returns:
        a newly created builder.
      • build

        public Cache build()
        Description copied from interface: Cache.CacheBuilder
        Creates a Cache instance.
        Returns:
        a cache.
      • maxItems

        public B maxItems​(int maxItems)
        The maximum number of cache entries. After reaching the limit the eldest entries will be evicted. Default is 8192.
        Parameters:
        maxItems - The maximum number of cache entries. Should be positive.
        Returns:
        builder itself.
      • size

        public B size​(long size)
        The amount of bytes allowed to be stored. Negative value means no memory restriction is made. Note that only response body bytes are counted.
        Parameters:
        size - The maximum size in bytes. Negative for no size restriction.
        Returns:
        builder itself.
      • requestFilter

        public B requestFilter​(java.util.function.Predicate<java.net.http.HttpRequest> filter)
        Adds given predicate to predicated chain. The calls with requests that did not pass given predicate will not be subjected to caching facility. Semantically request filter is equivalent to Cache-Control: no-store header in request.
        Parameters:
        filter - The request filter.
        Returns:
        builder itself.
      • responseFilter

        public B responseFilter​(java.util.function.Predicate<java.net.http.HttpResponse.ResponseInfo> filter)
        Adds given predicate to predicated chain. The calls resulting with response that did not pass given predicate will not be subjected to caching facility. Semantically response filter is equivalent to Cache-Control: no-store header in response.
        Parameters:
        filter - The request filter.
        Returns:
        builder itself.