## net.dontdrinkandroot.cache.impl.disk.file
Class FileCache

    java.lang.Object
      net.dontdrinkandroot.cache.impl.AbstractCache<K,V>
          net.dontdrinkandroot.cache.impl.AbstractMapBackedCache<Md5,File,SimpleMetaData>
              net.dontdrinkandroot.cache.impl.disk.file.FileCache

All Implemented Interfaces:
  Cache<Md5,File>

    public class FileCache

extends AbstractMapBackedCache<Md5,File,SimpleMetaData>

Author:
  Philip W. Sorst <philip@sorst.net>

Field Summary
`static Pattern` `MD5_PATTERN`

Fields inherited from interface net.dontdrinkandroot.cache.Cache
`UNLIMITED_IDLE_TIME`

Constructor Summary
`FileCache(String name, long defaultTimeToLive, long defaultMaxIdleTime, ExpungeStrategy expungeStrategy, File baseDir, int directoryDepth)`

Method Summary
`protected void` `createDirStructure(File dir, int directoryDepth)` Recursively creates directories 0x0 - 0xF until the desired depth is reached.
`protected void` `doDelete(Md5 key, SimpleMetaData metaData)` Performs deletion of the data belonging to the metadata.
`protected File` `doGet(Md5 key, SimpleMetaData metaData)` Performs retrieval of the data belonging to the metadata.
`protected File` `doPut(Md5 md5, File data)` Performs storage of the given data and adds new metadata to the map.
`File` `getBaseDir()`
`protected String` `getFileName(Md5 md5)`
`protected Map<Md5,SimpleMetaData>` `readInitialMap()`

Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractMapBackedCache
`cleanUp, delete, delete, expunge, get, getEntriesMetaData, getEntriesMetaDataMap, getExpungeStrategy, getMetaData, getStatistics, getWithErrors, put, putWithErrors, setEntriesMetaDataMap, setExpungeStrategy`

Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractCache
`getCleanUpLogger, getDefaultMaxIdleTime, getDefaultTtl, getLogger, getName, setDefaultMaxIdleTime, setDefaultTtl`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface net.dontdrinkandroot.cache.Cache
`getDefaultMaxIdleTime, getDefaultTtl, getName`

Field Detail

### MD5_PATTERN

    public static Pattern MD5_PATTERN

Constructor Detail

### FileCache

    public FileCache(String name,
                     long defaultTimeToLive,
                     long defaultMaxIdleTime,
                     ExpungeStrategy expungeStrategy,
                     File baseDir,
                     int directoryDepth)
              throws IOException,
                     CacheException

Throws:
  `IOException`
  `CacheException`

Method Detail

### doDelete

    protected void doDelete(Md5 key,
                            SimpleMetaData metaData)
                     throws CacheException

  Description copied from class: `AbstractMapBackedCache`
  Performs deletion of the data belonging to the metadata. Removal from the map is done by the superclass.

  Specified by:
    `doDelete` in class `AbstractMapBackedCache<Md5,File,SimpleMetaData>`
  Throws:
    `CacheException`

### doGet

    protected File doGet(Md5 key,
                         SimpleMetaData metaData)
                  throws CacheException

  Description copied from class: `AbstractMapBackedCache`
  Performs retrieval of the data belonging to the metadata.

  Specified by:
    `doGet` in class `AbstractMapBackedCache<Md5,File,SimpleMetaData>`
  Throws:
    `CacheException`

### doPut

    protected File doPut(Md5 md5,
                         File data)
                  throws CacheException

  Description copied from class: `AbstractMapBackedCache`
  Performs storage of the given data and adds new metadata to the map.

  Specified by:
    `doPut` in class `AbstractMapBackedCache<Md5,File,SimpleMetaData>`
  Throws:
    `CacheException`

### getBaseDir

    public final File getBaseDir()

### createDirStructure

    protected void createDirStructure(File dir,
                                      int directoryDepth)
                               throws IOException

  Recursively creates directories 0x0 - 0xF until the desired depth is reached.

  Parameters:
    `dir` - The base directory.
    `directoryDepth` - The level of nesting [0,...].
  Throws:
    `IOException`

### getFileName

    protected String getFileName(Md5 md5)

### readInitialMap

    protected Map<Md5,SimpleMetaData> readInitialMap()
                                              throws CacheException

  Throws:
    `CacheException`

Copyright © 2013 dontdrinkandroot. All Rights Reserved.