public abstract class FileCache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Cache<java.io.File,byte[]> |
cache |
protected int |
maxFileSize |
protected int |
maxSize |
protected long |
timeout |
protected int |
usedSize |
Modifier | Constructor and Description |
---|---|
protected |
FileCache(int maxSize,
int maxFileSize,
long timeout)
Creates new File LFU cache.
|
Modifier and Type | Method and Description |
---|---|
int |
cachedFilesCount()
Returns number of cached files.
|
long |
cacheTimeout()
Returns timeout.
|
void |
clear()
Clears the cache.
|
protected abstract Cache<java.io.File,byte[]> |
createCache()
Creates new cache instance for files content.
|
protected jodd.cache.AbstractCacheMap.CacheObject<java.io.File,byte[]> |
createFileCacheObject(java.io.File fileKey,
byte[] object,
long timeout)
Creates CacheObject that updates last access time based on files last modification.
|
byte[] |
getFileBytes(java.io.File file)
Returns cached file bytes.
|
int |
maxFileSize()
Returns maximum allowed file size that can be added to the cache.
|
int |
maxSize()
Returns max cache size in bytes.
|
int |
usedSize()
Returns actually used size in bytes.
|
protected final Cache<java.io.File,byte[]> cache
protected final int maxSize
protected final int maxFileSize
protected final long timeout
protected int usedSize
protected FileCache(int maxSize, int maxFileSize, long timeout)
maxSize
- total cache size in bytesmaxFileSize
- max available file size in bytes, may be 0timeout
- timeout, may be 0protected abstract Cache<java.io.File,byte[]> createCache()
protected jodd.cache.AbstractCacheMap.CacheObject<java.io.File,byte[]> createFileCacheObject(java.io.File fileKey, byte[] object, long timeout)
public int maxSize()
public int usedSize()
public int maxFileSize()
public int cachedFilesCount()
public long cacheTimeout()
public void clear()
public byte[] getFileBytes(java.io.File file) throws java.io.IOException
java.io.IOException
Copyright © 2003-present Jodd Team