Class FlatFileCache

  • public class FlatFileCache
    extends Object
    Provides a cache for storing multiple small files in memory. Can be used to e.g cache gzip compressed PDB files for avoiding disk IO bottlenecks. Note this is just a wrapper for the singleton cache.
    Andreas Prlic.
    • Method Detail

      • addToCache

        public static void addToCache​(String key,
                                      File fileToCache)
        The file is read and the bytes stored immediately.

        Once added, fileToCache can be modified or deleted and the cached values will not change.

        key -
        fileToCache - A readable file, of Integer.MAX bytes length or less.
      • getInputStream

        public static InputStream getInputStream​(String key)
        Gets the cached file as an InputStream. Clients should check for null as the item might have expired in the cache.
        key -
        An InputStream or null.
      • size

        public static int size()
        Returns the number of items in the cache. If the cache is {@}, returns -1
      • clear

        public static void clear()
        Removes all elements from the cache