public class FileCacheImpl extends Object implements Cache
This implementation uses a computing map LRU map to create missing entries, and an eviction listener to identify files that need to be deleted.
Concurrent control to the contents of each cache entry is implemented in StreamsCache
Cache.StreamProvider, Cache.TwoStreamProvider| Constructor and Description |
|---|
FileCacheImpl(File tmpDir,
int maxSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
cache(String bucket,
String key,
OutputStream out,
Cache.StreamProvider provider)
Stream the contents identified by the key to the destination stream.
|
void |
cacheTwo(String bucket,
String key,
OutputStream out1,
OutputStream out2,
Cache.TwoStreamProvider provider)
Stream two contents identified by the key to the destination stream.
|
void |
clear()
Remove all entries in the cache.
|
static OutputStream |
ensureNotNull(OutputStream stream) |
protected String |
generateNextFileName()
Atomically generates next file name for the cache file.
|
protected static final String EXT
public FileCacheImpl(File tmpDir, int maxSize) throws IOException
tmpDir - directory to store cache contents. Files in this dir will be deleted by constructormaxSize - size of the LRU cache. zero means evict-immediatelyIOExceptionpublic void cache(String bucket, String key, OutputStream out, Cache.StreamProvider provider)
Cachepublic void cacheTwo(String bucket, String key, OutputStream out1, OutputStream out2, Cache.TwoStreamProvider provider)
Cachepublic void clear()
Cachepublic static OutputStream ensureNotNull(OutputStream stream)
protected String generateNextFileName()
Copyright © 2017 Atlassian. All rights reserved.