This commit is contained in:
Looly
2019-10-29 19:05:23 +08:00
parent 3cef7fa9a7
commit bf03aebcef
107 changed files with 283 additions and 456 deletions

View File

@@ -83,14 +83,6 @@ public interface Cache<K, V> extends Iterable<V>, Serializable {
*/
V get(K key, boolean isUpdateLastAccess);
/**
* 返回缓存迭代器
*
* @return 缓存迭代器
*/
@Override
Iterator<V> iterator();
/**
* 返回包含键和值得迭代器
*

View File

@@ -45,20 +45,19 @@ public class LFUFileCache extends AbstractFileCache{
@Override
protected Cache<File, byte[]> initCache() {
Cache<File, byte[]> cache = new LFUCache<File, byte[]>(this.capacity, this.timeout) {
private static final long serialVersionUID = 1L;
return new LFUCache<File, byte[]>(LFUFileCache.this.capacity, LFUFileCache.this.timeout) {
private static final long serialVersionUID1 = 1L;
@Override
public boolean isFull() {
return LFUFileCache.this.usedSize > this.capacity;
}
@Override
protected void onRemove(File key, byte[] cachedObject) {
usedSize -= cachedObject.length;
}
};
return cache;
}
}

View File

@@ -45,20 +45,19 @@ public class LRUFileCache extends AbstractFileCache{
@Override
protected Cache<File, byte[]> initCache() {
Cache<File, byte[]> cache = new LRUCache<File, byte[]>(this.capacity, super.timeout) {
private static final long serialVersionUID = 1L;
return new LRUCache<File, byte[]>(LRUFileCache.this.capacity, super.timeout) {
private static final long serialVersionUID1 = 1L;
@Override
public boolean isFull() {
return LRUFileCache.this.usedSize > this.capacity;
}
@Override
protected void onRemove(File key, byte[] cachedObject) {
usedSize -= cachedObject.length;
}
};
return cache;
}
}

View File

@@ -20,7 +20,7 @@ public class CacheObj<K, V> implements Serializable{
/** 访问次数 */
protected long accessCount;
/** 对象存活时长0表示永久存活*/
private long ttl;
private final long ttl;
/**
* 构造

View File

@@ -23,7 +23,6 @@ public class CacheObjIterator<K, V> implements Iterator<CacheObj<K, V>>, Seriali
* 构造
*
* @param iterator 原{@link Iterator}
* @param readLock 读锁
*/
CacheObjIterator(Iterator<CacheObj<K, V>> iterator) {
this.iterator = iterator;

View File

@@ -17,7 +17,6 @@ public class CacheValuesIterator<V> implements Iterator<V>, Serializable {
/**
* 构造
* @param iterator 原{@link CacheObjIterator}
* @param readLock 读锁
*/
CacheValuesIterator(CacheObjIterator<?, V> iterator) {
this.cacheObjIter = iterator;