cal101 83c30bcfb7 [cleanup] erefactor/EclipseJdt - Remove trailing whitespace - All lines
EclipseJdt cleanup 'RemoveAllTrailingWhitespace' applied by erefactor.

For EclipseJdt see https://www.eclipse.org/eclipse/news/4.18/jdt.php
For erefactor see https://github.com/cal101/erefactor
2021-02-27 09:54:17 +00:00

64 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cn.hutool.cache.file;
import java.io.File;
import cn.hutool.cache.Cache;
import cn.hutool.cache.impl.LFUCache;
/**
* 使用LFU缓存文件以解决频繁读取文件引起的性能问题
* @author Looly
*
*/
public class LFUFileCache extends AbstractFileCache{
private static final long serialVersionUID = 1L;
/**
* 构造<br>
* 最大文件大小为缓存容量的一半<br>
* 默认无超时
* @param capacity 缓存容量
*/
public LFUFileCache(int capacity) {
this(capacity, capacity / 2, 0);
}
/**
* 构造<br>
* 默认无超时
* @param capacity 缓存容量
* @param maxFileSize 最大文件大小
*/
public LFUFileCache(int capacity, int maxFileSize) {
this(capacity, maxFileSize, 0);
}
/**
* 构造
* @param capacity 缓存容量
* @param maxFileSize 文件最大大小
* @param timeout 默认超时时间0表示无默认超时
*/
public LFUFileCache(int capacity, int maxFileSize, long timeout) {
super(capacity, maxFileSize, timeout);
}
@Override
protected Cache<File, byte[]> initCache() {
return new LFUCache<File, byte[]>(LFUFileCache.this.capacity, LFUFileCache.this.timeout) {
private static final long serialVersionUID = 1L;
@Override
public boolean isFull() {
return LFUFileCache.this.usedSize > this.capacity;
}
@Override
protected void onRemove(File key, byte[] cachedObject) {
usedSize -= cachedObject.length;
}
};
}
}