public abstract class AbstractFileCache extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected Cache<File,byte[]> |
cache
缓存实现
|
protected int |
capacity
容量
|
protected int |
maxFileSize
缓存的最大文件大小,文件大于此大小时将不被缓存
|
protected long |
timeout
默认超时时间,0表示无默认超时
|
protected int |
usedSize
已使用缓存空间
|
| Constructor and Description |
|---|
AbstractFileCache(int capacity,
int maxFileSize,
long timeout)
构造
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity() |
void |
clear()
清空缓存
|
int |
getCachedFilesCount() |
byte[] |
getFileBytes(File file)
获得缓存过的文件bytes
|
byte[] |
getFileBytes(String path)
获得缓存过的文件bytes
|
int |
getUsedSize() |
protected abstract Cache<File,byte[]> |
initCache()
初始化实现文件缓存的缓存对象
|
int |
maxFileSize() |
long |
timeout() |
protected final int capacity
protected final int maxFileSize
protected final long timeout
protected int usedSize
public AbstractFileCache(int capacity,
int maxFileSize,
long timeout)
capacity - 缓存容量maxFileSize - 文件最大大小timeout - 默认超时时间,0表示无默认超时public int capacity()
public int getUsedSize()
public int maxFileSize()
public int getCachedFilesCount()
public long timeout()
public void clear()
public byte[] getFileBytes(String path) throws IORuntimeException
path - 文件路径IORuntimeException - IO异常public byte[] getFileBytes(File file) throws IORuntimeException
file - 文件IORuntimeException - IO异常Copyright © 2025. All rights reserved.