com.nostra13.universalimageloader.cache.disc
Class LimitedDiscCache
java.lang.Object
com.nostra13.universalimageloader.cache.disc.BaseDiscCache
com.nostra13.universalimageloader.cache.disc.LimitedDiscCache
- All Implemented Interfaces:
- DiscCacheAware
- Direct Known Subclasses:
- FileCountLimitedDiscCache, TotalSizeLimitedDiscCache
public abstract class LimitedDiscCache
- extends BaseDiscCache
Abstract disc cache limited by some parameter. If cache exceeds specified limit then file with the most oldest last
usage date will be deleted.
- Since:
- 1.0.0
- Author:
- Sergey Tarasevich (nostra13[at]gmail[dot]com)
- See Also:
BaseDiscCache
,
FileNameGenerator
Method Summary |
void |
clear()
Clears cache directory |
java.io.File |
get(java.lang.String key)
Returns file object appropriate incoming key. |
protected abstract int |
getSize(java.io.File file)
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LimitedDiscCache
public LimitedDiscCache(java.io.File cacheDir,
int sizeLimit)
- Parameters:
cacheDir
- Directory for file caching. Important: Specify separate folder for cached files. It's
needed for right cache limit work.sizeLimit
- Cache limit value. If cache exceeds this limit then file with the most oldest last usage date
will be deleted.
LimitedDiscCache
public LimitedDiscCache(java.io.File cacheDir,
FileNameGenerator fileNameGenerator,
int sizeLimit)
- Parameters:
cacheDir
- Directory for file caching. Important: Specify separate folder for cached files. It's
needed for right cache limit work.fileNameGenerator
- Name generator for cached filessizeLimit
- Cache limit value. If cache exceeds this limit then file with the most oldest last usage date
will be deleted.
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
clear
public void clear()
- Description copied from interface:
DiscCacheAware
- Clears cache directory
- Specified by:
clear
in interface DiscCacheAware
- Overrides:
clear
in class BaseDiscCache
getSize
protected abstract int getSize(java.io.File file)
Copyright © 2011-2013. All Rights Reserved.