Class Cache


  • public class Cache
    extends java.lang.Object
    The cache class represents the local disk cache. It is used for storing multichunks or other metadata files before upload, and as a download location for the same files.

    The cache implements an LRU strategy based on the last modified date of the cached files. When files are accessed using the respective getters, the last modified date is updated. Using the clear()/clear(long) method, the cache can be cleaned.

    • Constructor Summary

      Constructors 
      Constructor Description
      Cache​(java.io.File cacheDir)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Deletes files in the the cache directory using a LRU-strategy until keepBytes bytes are left.
      void clear​(long keepBytes)
      Deletes files in the the cache directory using a LRU-strategy until keepBytes bytes are left.
      java.io.File createTempFile​(java.lang.String name)
      Creates temporary file in the local directory cache, typically located at .syncany/cache.
      java.io.File getDatabaseFile​(java.lang.String name)
      Returns a file path of a database remote file.
      java.io.File getDecryptedMultiChunkFile​(MultiChunkEntry.MultiChunkId multiChunkId)
      Returns a file path of a decrypted multichunk file, given the identifier of a multichunk.
      java.io.File getEncryptedMultiChunkFile​(MultiChunkEntry.MultiChunkId multiChunkId)
      Returns a file path of a encrypted multichunk file, given the identifier of a multichunk.
      long getKeepBytes()  
      void setKeepBytes​(long keepBytes)  
      • Methods inherited from class java.lang.Object

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

      • Cache

        public Cache​(java.io.File cacheDir)
    • Method Detail

      • getDatabaseFile

        public java.io.File getDatabaseFile​(java.lang.String name)
        Returns a file path of a database remote file.
      • setKeepBytes

        public void setKeepBytes​(long keepBytes)
      • clear

        public void clear()
        Deletes files in the the cache directory using a LRU-strategy until keepBytes bytes are left. This method calls clear(long) using the keepBytes property.

        This method should not be run while an operation is executed.

      • clear

        public void clear​(long keepBytes)
        Deletes files in the the cache directory using a LRU-strategy until keepBytes bytes are left.

        This method should not be run while an operation is executed.

      • createTempFile

        public java.io.File createTempFile​(java.lang.String name)
                                    throws java.io.IOException
        Creates temporary file in the local directory cache, typically located at .syncany/cache. If not deleted by the application, the returned file is automatically deleted on exit by the JVM.
        Returns:
        Temporary file in local directory cache
        Throws:
        java.io.IOException