类 | |
| class | CacheHeader |
| class | CountingInputStream |
Public 成员函数 | |
| DiskBasedCache (File rootDirectory, int maxCacheSizeInBytes) | |
| DiskBasedCache (File rootDirectory) | |
| synchronized void | clear () |
| synchronized Entry | get (String key) |
| synchronized void | initialize () |
| synchronized void | invalidate (String key, boolean fullExpire) |
| synchronized void | put (String key, Entry entry) |
| synchronized void | remove (String key) |
| File | getFileForKey (String key) |
静态包函数 | |
| static void | writeInt (OutputStream os, int n) throws IOException |
| static int | readInt (InputStream is) throws IOException |
| static void | writeLong (OutputStream os, long n) throws IOException |
| static long | readLong (InputStream is) throws IOException |
| static void | writeString (OutputStream os, String s) throws IOException |
| static String | readString (InputStream is) throws IOException |
| static void | writeStringStringMap (Map< String, String > map, OutputStream os) throws IOException |
| static Map< String, String > | readStringStringMap (InputStream is) throws IOException |
Private 成员函数 | |
| String | getFilenameForKey (String key) |
| void | pruneIfNeeded (int neededSpace) |
| void | putEntry (String key, CacheHeader entry) |
| void | removeEntry (String key) |
静态 Private 成员函数 | |
| static byte[] | streamToBytes (InputStream in, int length) throws IOException |
| static int | read (InputStream is) throws IOException |
Private 属性 | |
| final Map< String, CacheHeader > | mEntries |
| long | mTotalSize = 0 |
| final File | mRootDirectory |
| final int | mMaxCacheSizeInBytes |
静态 Private 属性 | |
| static final int | DEFAULT_DISK_USAGE_BYTES = 5 * 1024 * 1024 |
| static final float | HYSTERESIS_FACTOR = 0.9f |
| static final int | CACHE_MAGIC = 0x20120504 |
Cache implementation that caches files directly onto the hard disk in the specified directory. The default disk usage size is 5MB, but is configurable.
|
inline |
Constructs an instance of the DiskBasedCache at the specified directory.
| rootDirectory | The root directory of the cache. |
| maxCacheSizeInBytes | The maximum size of the cache in bytes. |
|
inline |
Constructs an instance of the DiskBasedCache at the specified directory using the default maximum cache size of 5MB.
| rootDirectory | The root directory of the cache. |
|
inline |
Clears the cache. Deletes all cached files from disk.
|
inline |
Returns the cache entry with the specified key if it exists, null otherwise.
|
inline |
Returns a file object for the given cache key.
|
inlineprivate |
Creates a pseudo-unique filename for the specified cache key.
| key | The key to generate a file name for. |
|
inline |
Initializes the DiskBasedCache by scanning for all files currently in the specified root directory. Creates the root directory if necessary.
|
inline |
Invalidates an entry in the cache.
| key | Cache key |
| fullExpire | True to fully expire the entry, false to soft expire |
|
inlineprivate |
Prunes the cache to fit the amount of bytes specified.
| neededSpace | The amount of bytes we are trying to fit into the cache. |
|
inline |
Puts the entry with the specified key into the cache.
|
inlineprivate |
Puts the entry with the specified key into the cache.
| key | The key to identify the entry by. |
| entry | The entry to cache. |
|
inlinestaticprivate |
Simple wrapper around InputStream#read() that throws EOFException instead of returning -1.
|
inlinestaticpackage |
|
inlinestaticpackage |
|
inlinestaticpackage |
|
inlinestaticpackage |
|
inline |
Removes the specified key from the cache if it exists.
|
inlineprivate |
Removes the entry identified by 'key' from the cache.
|
inlinestaticprivate |
Reads the contents of an InputStream into a byte[].
|
inlinestaticpackage |
|
inlinestaticpackage |
|
inlinestaticpackage |
|
inlinestaticpackage |
|
staticprivate |
Magic number for current version of cache file format.
|
staticprivate |
Default maximum disk usage in bytes.
|
staticprivate |
High water mark percentage for the cache
|
private |
Map of the Key, CacheHeader pairs
|
private |
The maximum size of the cache in bytes.
|
private |
The root directory to use for the cache.
|
private |
Total amount of space currently used by the cache in bytes.
1.8.8