use of com.ljy.devring.cache.support.DiskCache in project DevRing by LJYcoder.
the class CacheManager method diskCache.
public DiskCache diskCache(String cacheName) {
File cacheDir;
if (isSpace(cacheName))
cacheName = "cache_default";
if (mCacheConfig.getDiskCacheFolder() != null && mCacheConfig.getDiskCacheFolder().isDirectory()) {
cacheDir = new File(mCacheConfig.getDiskCacheFolder(), cacheName);
} else {
cacheDir = new File(FileUtil.getCacheDir(mContext), cacheName);
}
String cacheKey = cacheDir.getAbsoluteFile() + "_" + Process.myPid();
DiskCache cache = mMapDiskCache.get(cacheKey);
if (cache == null) {
long maxSize = mCacheConfig.getDiskCacheMaxSize() > 0 ? mCacheConfig.getDiskCacheMaxSize() : DEFAULT_DISK_CACHE_MAX_SIZE;
int maxCount = mCacheConfig.getDiskCacheMaxCount() > 0 ? mCacheConfig.getDiskCacheMaxCount() : DEFAULT_DISK_CACHE_MAX_COUNT;
cache = new DiskCache(mContext, cacheDir, maxSize, maxCount);
mMapDiskCache.put(cacheKey, cache);
}
return cache;
}