Package org.nuxeo.common.file
Interface FileCache
-
- All Known Implementing Classes:
LRUFileCache
public interface FileCacheA cache ofFiles.The cache uses application-chosen keys.
To check presence in the cache, use
getFile(java.lang.String).To put a new
InputStreamin the cache, useputFile(String, InputStream). Or if you'd like aFileobject into which to write some data, get one usinggetTempFile(), put the actual binary in it, then pass this file toputFile(String, File).- See Also:
LRUFileCache
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Clears the cache.FilegetFile(String key)Gets a file from the cache.intgetNumberOfItems()Gets the number of items in the cache.longgetSize()Gets the size of the cache, in bytes.FilegetTempFile()Creates a temporary file.FileputFile(String key, File file)Puts a file in the cache.FileputFile(String key, InputStream in)Puts a file in the cache.
-
-
-
Method Detail
-
getSize
long getSize()
Gets the size of the cache, in bytes.
-
getNumberOfItems
int getNumberOfItems()
Gets the number of items in the cache.
-
getTempFile
File getTempFile() throws IOException
Creates a temporary file.- Throws:
IOException
-
putFile
File putFile(String key, InputStream in) throws IOException
Puts a file in the cache.- Parameters:
key- the cache keyin- the input stream to cache (closed afterwards)- Returns:
- the cached file
- Throws:
IllegalArgumentException- if the key is illegalIOException
-
putFile
File putFile(String key, File file) throws IOException
Puts a file in the cache.The file must have been created through
getTempFile(). The file is "given" to this method, who will delete it or rename it.- Parameters:
key- the cache keyfile- the file to cache- Returns:
- the cached file
- Throws:
IllegalArgumentException- if the key is illegalIOException
-
getFile
File getFile(String key)
Gets a file from the cache.A returned file will never be deleted from the filesystem while the returned file object is still referenced, although it may be purged from the cache.
- Parameters:
key- the cache key- Returns:
- the cached file, or
nullif absent
-
clear
void clear()
Clears the cache.Files will not be deleted from the filesystm while the returned file objects are still referenced.
-
-