com.atlassian.plugin.cache.filecache.impl
Class FileCacheImpl<K>
java.lang.Object
com.atlassian.plugin.cache.filecache.impl.FileCacheImpl<K>
- All Implemented Interfaces:
- FileCache<K>
public class FileCacheImpl<K>
- extends Object
- implements FileCache<K>
Implements a thread-safe FileCache.
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 CachedFile
- Since:
- v2.13
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileCacheImpl
public FileCacheImpl(File tmpDir,
int maxSize,
AtomicLong filenameCounter)
throws IOException
- Parameters:
tmpDir - directory to store cache contents. Files in this dir will be deleted by constructormaxSize - size of the LRU cache. zero means evict-immediatelyfilenameCounter - counter for cache filenames. Passed in to allow multiple instances to share the same counter.
- Throws:
IOException
stream
public void stream(K key,
OutputStream dest,
FileCacheStreamProvider input)
throws DownloadException
- Description copied from interface:
FileCache
- Stream the contents identified by the key to the destination stream. Should the contents not exist in the cache
a new entry should be created if the implementation is a caching implementation.
- Specified by:
stream in interface FileCache<K>
- Parameters:
key - can not be nulldest - where to write the cached item toinput - provides the underlying item on a cache-miss
- Throws:
DownloadException - if there was an error writing to dest, or reading from input, or reading from the cache
clear
public void clear()
- Description copied from interface:
FileCache
- Remove all entries in the cache.
- Specified by:
clear in interface FileCache<K>
Copyright © 2013 Atlassian. All Rights Reserved.