Class HttpCacheImpl

    • Method Detail

      • isValid

        public boolean isValid​(String key)
        Description copied from interface: FileCache
        Check if file under given key, is valid.
        Specified by:
        isValid in interface FileCache
        Parameters:
        key - key to check
        Returns:
        true - if file exists and is valid. False otherwise.
      • getFile

        @NotNull
        public File getFile​(@NotNull
                            String key)
                     throws IOException
        Description copied from interface: FileCache
        Get cached file. Ensures file is in cache directory and is valid. Updates file, if necessary.
        Specified by:
        getFile in interface FileCache
        Parameters:
        key - key for file.
        Returns:
        file in cache directory
        Throws:
        IOException - if error occures.
      • putFiles

        public void putFiles​(@NotNull
                             Map<String,​File> keyToFileMap,
                             @NotNull
                             Map<File,​String> fileToDigestMap)
                      throws IOException
        Description copied from interface: LocalCache
        Put files into cache under given keys.
        Specified by:
        putFiles in interface LocalCache
        Parameters:
        keyToFileMap - mapping of keys to files
        fileToDigestMap - mapping of files to file digests
        Throws:
        IOException
      • getCachedFile

        @Nullable
        public File getCachedFile​(@NotNull
                                  String key,
                                  @NotNull
                                  String expectedDigest)
        Specified by:
        getCachedFile in interface LocalCache
        Returns:
        cached file for specified key if the file exists and is valid, otherwise null
      • delete

        public void delete​(@NotNull
                           String key)
        Description copied from interface: LocalCache
        Delete cache entry. Deletes cache entry and underlying content file.
        Specified by:
        delete in interface LocalCache
        Parameters:
        key - key to delete
      • listCache

        @NotNull
        public Collection<File> listCache()
        Description copied from interface: LocalCache
        List cache content.
        Specified by:
        listCache in interface LocalCache
        Returns:
        collection of all files on disk in cache
      • cleanUpCache

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

        public void cleanUpCache​(long itemLifeTimeMillis)
        Description copied from interface: LocalCache
        Delete items from cache whose life time in cache is greater than specified value
        Specified by:
        cleanUpCache in interface LocalCache
      • cleanUpCache

        public void cleanUpCache()
        Description copied from interface: LocalCache
        Cleanup cache: delete outdated items according to current cache options
        Specified by:
        cleanUpCache in interface LocalCache