com.nostra13.universalimageloader.cache.disc.impl
Class LimitedAgeDiscCache

java.lang.Object
  extended by com.nostra13.universalimageloader.cache.disc.BaseDiscCache
      extended by com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiscCache
All Implemented Interfaces:
DiscCacheAware

public class LimitedAgeDiscCache
extends BaseDiscCache

Cache which deletes files which were loaded more than defined time. Cache size is unlimited.

Author:
Sergey Tarasevich (nostra13[at]gmail[dot]com)
See Also:
BaseDiscCache

Constructor Summary
LimitedAgeDiscCache(java.io.File cacheDir, FileNameGenerator fileNameGenerator, long maxAge)
           
LimitedAgeDiscCache(java.io.File cacheDir, long maxAge)
           
 
Method Summary
 java.io.File get(java.lang.String key)
          Returns file object appropriate incoming key.
 void put(java.lang.String key, java.io.File file)
          This method must not to save file on file system in fact.
 
Methods inherited from class com.nostra13.universalimageloader.cache.disc.BaseDiscCache
clear, getCacheDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitedAgeDiscCache

public LimitedAgeDiscCache(java.io.File cacheDir,
                           long maxAge)
Parameters:
cacheDir - Directory for file caching
maxAge - Max file age (in seconds). If file age will exceed this value then it'll be removed on next treatment (and therefore be reloaded).

LimitedAgeDiscCache

public LimitedAgeDiscCache(java.io.File cacheDir,
                           FileNameGenerator fileNameGenerator,
                           long maxAge)
Parameters:
cacheDir - Directory for file caching
fileNameGenerator - Name generator for cached files
maxAge - Max file age (in seconds). If file age will exceed this value then it'll be removed on next treatment (and therefore be reloaded).
Method Detail

put

public void put(java.lang.String key,
                java.io.File file)
Description copied from interface: DiscCacheAware
This method must not to save file on file system in fact. It is called after image was cached in cache directory and it was decoded to bitmap in memory. Such order is required to prevent possible deletion of file after it was cached on disc and before it was tried to decode to bitmap.


get

public java.io.File get(java.lang.String key)
Description copied from interface: DiscCacheAware
Returns file object appropriate incoming key.
NOTE: Must not to return a null. Method must return specific file object for incoming key whether file exists or not.

Specified by:
get in interface DiscCacheAware
Overrides:
get in class BaseDiscCache


Copyright © 2011-2013. All Rights Reserved.