Interface LocalCache

  • All Known Subinterfaces:
    FileCache
    All Known Implementing Classes:
    HttpCacheImpl

    public interface LocalCache
    Created by Nikita Skvortsov date: 02.10.13.
    • Method Detail

      • putFile

        void putFile​(@NotNull
                     String key,
                     @NotNull
                     File file)
              throws IOException
        Put file into cache under given key.
        Parameters:
        key -
        file -
        Throws:
        IOException
      • putFile

        void putFile​(@NotNull
                     String key,
                     @NotNull
                     File file,
                     @Nullable
                     String digest)
              throws IOException
        Put file into cache under given key with given digest.
        Parameters:
        key -
        file -
        digest -
        Throws:
        IOException
      • putFiles

        void putFiles​(@NotNull
                      Map<String,​File> keyToFileMap,
                      @NotNull
                      Map<File,​String> fileToDigestMap)
               throws IOException
        Put files into cache under given keys.
        Parameters:
        keyToFileMap - mapping of keys to files
        fileToDigestMap - mapping of files to file digests
        Throws:
        IOException
      • delete

        void delete​(@NotNull
                    String key)
        Delete cache entry. Deletes cache entry and underlying content file.
        Parameters:
        key - key to delete
      • listCache

        @NotNull
        Collection<File> listCache()
        List cache content.
        Returns:
        collection of all files on disk in cache
      • getCacheOptions

        @NotNull
        CacheOptions getCacheOptions()
        Get cache options
        Returns:
        current cache options
      • cleanUpCache

        void cleanUpCache()
        Cleanup cache: delete outdated items according to current cache options
      • cleanUpCache

        void cleanUpCache​(long curMaxLifeTimeMs,
                          Condition<Void> isInterrupted)
        Delete items from cache whose life time in cache is greater than specified value Allows to interrupt.
        Parameters:
        curMaxLifeTimeMs -
        isInterrupted - predicate to check for interrupt
      • cleanUpCache

        void cleanUpCache​(long itemLifeTimeMillis)
        Delete items from cache whose life time in cache is greater than specified value
      • getCachedFile

        @Nullable
        File getCachedFile​(@NotNull
                           String key,
                           @NotNull
                           String expectedDigest)
        Returns:
        cached file for specified key if the file exists and is valid, otherwise null