1package com.bumptech.glide.load.engine.cache; 2 3import com.bumptech.glide.load.Key; 4 5import java.io.InputStream; 6import java.io.OutputStream; 7 8/** 9 * An interface for writing to and reading from a disk cache 10 */ 11public interface DiskCache { 12 /** 13 * An interface to actually write data to a key in 14 * the disk cache 15 */ 16 public interface Writer { 17 /** 18 * Writes data to the output stream and returns true if the write was successful and should be committed, and 19 * false if the write should be aborted. 20 * 21 * @param os The output stream the Writer should write to. 22 */ 23 public boolean write(OutputStream os); 24 } 25 26 /** 27 * Get an InputStream for the value at the given key. 28 * 29 * @param key The key in the cache 30 * @return An InputStream representing the data at key at the time get is called 31 */ 32 public InputStream get(Key key); 33 34 /** 35 * Write to a key in the cache. {@link Writer} is used so that the cache implementation 36 * can perform actions after the write finishes, like commit (via atomic file rename). 37 * 38 * @param key The key to write to 39 * @param writer An interface that will write data given an OutputStream for the key 40 */ 41 public void put(Key key, Writer writer); 42 43 /** 44 * Remove the key and value from the cache 45 * 46 * @param key The key to remove 47 */ 48 public void delete(Key key); 49} 50