1 package com.atlassian.plugin.cache.filecache;
2
3 import com.atlassian.plugin.servlet.DownloadException;
4
5 import java.io.OutputStream;
6
7 /**
8 * Represents a file cache.
9 * @since 2.13
10 * @param <K> Key of the cache, should conform the requirements for keys of {@link java.util.Map}.
11 */
12 public interface FileCache<K> {
13
14 /**
15 * Stream the contents identified by the key to the destination stream. Should the contents not exist in the cache
16 * a new entry should be created if the implementation is a caching implementation.
17 * @param key can not be null
18 * @param dest where to write the cached item to
19 * @param input provides the underlying item on a cache-miss
20 * @throws DownloadException if there was an error writing to dest, or reading from input, or reading from the cache
21 */
22 void stream(K key, OutputStream dest, FileCacheStreamProvider input) throws DownloadException;
23
24 /**
25 * Remove all entries in the cache.
26 */
27 void clear();
28 }