Package org.syncany.config
Class Cache
- java.lang.Object
-
- org.syncany.config.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 untilkeepBytes
bytes are left.void
clear(long keepBytes)
Deletes files in the the cache directory using a LRU-strategy untilkeepBytes
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)
-
-
-
Constructor Detail
-
Cache
public Cache(java.io.File cacheDir)
-
-
Method Detail
-
getDecryptedMultiChunkFile
public java.io.File getDecryptedMultiChunkFile(MultiChunkEntry.MultiChunkId multiChunkId)
Returns a file path of a decrypted multichunk file, given the identifier of a multichunk.
-
getEncryptedMultiChunkFile
public java.io.File getEncryptedMultiChunkFile(MultiChunkEntry.MultiChunkId multiChunkId)
Returns a file path of a encrypted multichunk file, given the identifier of a multichunk.
-
getDatabaseFile
public java.io.File getDatabaseFile(java.lang.String name)
Returns a file path of a database remote file.
-
getKeepBytes
public long getKeepBytes()
-
setKeepBytes
public void setKeepBytes(long keepBytes)
-
clear
public void clear()
Deletes files in the the cache directory using a LRU-strategy untilkeepBytes
bytes are left. This method callsclear(long)
using thekeepBytes
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 untilkeepBytes
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
-
-