Class ShaCache

java.lang.Object
aQute.libg.shacache.ShaCache

public class ShaCache extends Object
Provide a standardized cache based on the SHA-1 of a file.
  • Field Details

    • SHA_P

      private static final Pattern SHA_P
    • root

      private final File root
  • Constructor Details

    • ShaCache

      public ShaCache(File root)
      Create a SHA-1 cache on a directory.
      Parameters:
      root - the directory
  • Method Details

    • getStream

      public InputStream getStream(String sha, ShaSource... sources) throws Exception
      Return a stream that is associated with a SHA. If the SHA is not in the local cache, the given sources parameter can specify a way to get the content.
      Parameters:
      sha - the sha
      sources - objects that can retrieve the original data
      Returns:
      the stream or null if not found.
      Throws:
      Exception
    • getFile

      public File getFile(String sha, ShaSource... sources) throws Exception
      Small variation on the cache that returns a file instead of a stream
      Parameters:
      sha - the SHA-1
      sources - the inputs
      Returns:
      a file or null
      Throws:
      Exception
    • purge

      public void purge() throws Exception
      Clean the cache
      Throws:
      Exception
    • getRoot

      public File getRoot()
      Get the root to the cache