public abstract class CachingBinaryManager extends AbstractBinaryManager
BinaryManager
that uses a cache for its files because fetching them is expensive.
Initialization of the BinaryManager
must call initializeCache(java.io.File, long, org.nuxeo.ecm.core.storage.binary.FileStorage)
from the initialize(org.nuxeo.ecm.core.storage.binary.BinaryManagerDescriptor)
method.
Modifier and Type | Field and Description |
---|---|
FileCache |
fileCache |
DEFAULT_DEPTH, DEFAULT_DIGEST, MAX_BUF_SIZE, MIN_BUF_SIZE
Constructor and Description |
---|
CachingBinaryManager() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the binary manager and releases all resources and temporary objects held by it.
|
Binary |
getBinary(String digest)
Returns a
Binary corresponding to the given digest. |
File |
getFile(String digest)
Gets a file from cache or storage.
|
Long |
getLength(String digest)
Gets a file length from cache or storage.
|
void |
initialize(BinaryManagerDescriptor binaryManagerDescriptor)
Initializer.
|
void |
initializeCache(File dir,
long maxSize,
FileStorage fileStorage)
Initialize the cache.
|
void |
initializeCache(String cacheSizeStr,
FileStorage fileStorage)
Initialize the cache.
|
getBinary, getGarbageCollector, toHexString
public FileCache fileCache
public void initialize(BinaryManagerDescriptor binaryManagerDescriptor) throws IOException
BinaryManager
initialize
in interface BinaryManager
initialize
in class AbstractBinaryManager
IOException
public void initializeCache(File dir, long maxSize, FileStorage fileStorage)
dir
- the directory to use to store cached filesmaxSize
- the maximum size of the cache (in bytes)fileStorage
- the file storage mechanism to use to store and fetch filespublic void initializeCache(String cacheSizeStr, FileStorage fileStorage) throws IOException
cacheSizeStr
- the maximum size of the cache (as a String)fileStorage
- the file storage mechanism to use to store and fetch filesIOException
initializeCache(File, long, FileStorage)
,
SizeUtils.parseSizeInBytes(String)
public void close()
BinaryManager
public Binary getBinary(String digest)
BinaryManager
Binary
corresponding to the given digest.
A null
is returned if the digest could not be found.
getBinary
in interface BinaryManager
getBinary
in class AbstractBinaryManager
digest
- the digest, or null
public File getFile(String digest) throws IOException
Used by LazyBinary
.
IOException
public Long getLength(String digest) throws IOException
Use by LazyBinary
.
IOException
Copyright © 2015 Nuxeo SA. All rights reserved.