Class RedisTransientStore
- java.lang.Object
-
- org.nuxeo.ecm.core.transientstore.AbstractTransientStore
-
- org.nuxeo.ecm.core.redis.contribs.RedisTransientStore
-
- All Implemented Interfaces:
TransientStore
,TransientStoreProvider
public class RedisTransientStore extends AbstractTransientStore
Redis implementation (i.e. cluster aware) of theTransientStore
.Since hashes cannot be nested, a storage entry is flattened as follows:
- Entry summary: transientStore:transientStoreName:entryKey { "blobCount": number of blobs associated with the entry "size": storage size of the blobs associated with the entry "completed": entry status } - Entry parameters: transientStore:transientStoreName:entryKey:params { "param1": value1 "param2": value2 } - Entry blobs: transientStore:transientStoreName:entryKey:blobs:0 { "file" "filename" "encoding" "mimetype" "digest" } transientStore:transientStoreName:entryKey:blobs:1 { ... } ...
- Since:
- 7.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
RedisTransientStore.KeyMatcher
-
Field Summary
Fields Modifier and Type Field Description protected int
firstLevelTTL
protected RedisTransientStore.KeyMatcher
keyMatcher
protected Log
log
protected String
namespace
protected RedisAdmin
redisAdmin
protected RedisExecutor
redisExecutor
protected int
secondLevelTTL
protected static String
SIZE_KEY
protected String
sizeKey
-
Fields inherited from class org.nuxeo.ecm.core.transientstore.AbstractTransientStore
cacheDir, config
-
-
Constructor Summary
Constructors Constructor Description RedisTransientStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
decrementStorageSize(long size)
protected void
deleteBlobInfos(String key, String blobCountStr)
protected Serializable
deserialize(byte[] bytes)
protected Map<String,Serializable>
deserialize(Map<byte[],byte[]> byteMap)
boolean
exists(String key)
Returnstrue
if an entry exists with the givenkey
.List<Blob>
getBlobs(String key)
Gets the blobs associated with the entry with the givenkey
.protected byte[]
getBytes(String key)
Serializable
getParameter(String key, String parameter)
Gets the value ofparameter
in the entry with the givenkey
.Map<String,Serializable>
getParameters(String key)
Gets values of the parameters in the entry with the givenkey
.long
getSize(String key)
Returns the size of the blobs associated with the entry with the givenkey
or-1
if entry does not exist.long
getStorageSize()
Returns the size (in bytes) of the disk storage used for blobs.protected String
getString(byte[] bytes)
protected Map<String,String>
getSummary(String key)
long
getTTL(String key)
protected long
incrementStorageSize(long size)
void
init(TransientStoreConfig config)
Initializes the store from the givenconfig
.boolean
isCompleted(String key)
Returnstrue
if the entry with the givenkey
is ready.protected String
join(String... fragments)
Stream<String>
keyStream()
Returns aStream
of keys for all entries.protected void
persistBlobs(String key, long sizeOfBlobs, List<Map<String,String>> blobInfos)
Updates the total storage size and the storage size of the entry with the givenkey
according tosizeOfBlobs
and stores the blob information in this entry.void
putParameter(String key, String parameter, Serializable value)
Setsparameter
tovalue
in the entry with the givenkey
.void
putParameters(String key, Map<String,Serializable> parameters)
Putsparameters
in the entry with the givenkey
.void
release(String key)
Informs the store that the entry with the givenkey
can be released if TTL or GC parameters require to do some cleanup.protected void
removeAllEntries()
protected void
removeEntry(String key)
protected byte[]
serialize(Serializable value)
protected Map<byte[],byte[]>
serialize(Map<String,Serializable> map)
void
setCompleted(String key, boolean completed)
Marks the entry with the givenkey
as ready.protected void
setStorageSize(long newSize)
Sets the size of the disk storage in bytes.protected void
setTTL(String key, int seconds)
void
shutdown()
Shuts down the store.-
Methods inherited from class org.nuxeo.ecm.core.transientstore.AbstractTransientStore
doGC, getCacheDir, getCachingDirectory, getCachingDirName, getFilePathSize, getKeyCachingDirName, getSizeOfBlobs, loadBlobs, putBlobs, remove, removeAll, removeBlobs, storeBlobs
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.transientstore.api.TransientStoreProvider
getStorageSizeMB, keySet
-
-
-
-
Field Detail
-
SIZE_KEY
protected static final String SIZE_KEY
- See Also:
- Constant Field Values
-
redisExecutor
protected RedisExecutor redisExecutor
-
namespace
protected String namespace
-
sizeKey
protected String sizeKey
-
keyMatcher
protected RedisTransientStore.KeyMatcher keyMatcher
-
redisAdmin
protected RedisAdmin redisAdmin
-
firstLevelTTL
protected int firstLevelTTL
-
secondLevelTTL
protected int secondLevelTTL
-
log
protected Log log
-
-
Method Detail
-
init
public void init(TransientStoreConfig config)
Description copied from interface:TransientStoreProvider
Initializes the store from the givenconfig
.- Specified by:
init
in interfaceTransientStoreProvider
- Overrides:
init
in classAbstractTransientStore
-
shutdown
public void shutdown()
Description copied from interface:TransientStoreProvider
Shuts down the store.- Specified by:
shutdown
in interfaceTransientStoreProvider
- Specified by:
shutdown
in classAbstractTransientStore
-
exists
public boolean exists(String key)
Description copied from interface:TransientStore
Returnstrue
if an entry exists with the givenkey
.- Specified by:
exists
in interfaceTransientStore
- Specified by:
exists
in classAbstractTransientStore
-
keyStream
public Stream<String> keyStream()
Description copied from interface:TransientStoreProvider
Returns aStream
of keys for all entries.
-
putParameter
public void putParameter(String key, String parameter, Serializable value)
Description copied from interface:TransientStore
Setsparameter
tovalue
in the entry with the givenkey
.If entry does not exist a new entry is created. If
parameter
already exists in the entry it is overwritten.- Specified by:
putParameter
in interfaceTransientStore
- Specified by:
putParameter
in classAbstractTransientStore
-
getParameter
public Serializable getParameter(String key, String parameter)
Description copied from interface:TransientStore
Gets the value ofparameter
in the entry with the givenkey
.Returns
null
if entry or parameter does not exist.- Specified by:
getParameter
in interfaceTransientStore
- Specified by:
getParameter
in classAbstractTransientStore
-
putParameters
public void putParameters(String key, Map<String,Serializable> parameters)
Description copied from interface:TransientStore
Putsparameters
in the entry with the givenkey
. Overwrites any existing parameter in the entry.If entry does not exist a new entry is created.
- Specified by:
putParameters
in interfaceTransientStore
- Specified by:
putParameters
in classAbstractTransientStore
-
getParameters
public Map<String,Serializable> getParameters(String key)
Description copied from interface:TransientStore
Gets values of the parameters in the entry with the givenkey
.Returns
null
if entry does not exist.- Specified by:
getParameters
in interfaceTransientStore
- Specified by:
getParameters
in classAbstractTransientStore
-
getBlobs
public List<Blob> getBlobs(String key)
Description copied from interface:TransientStore
Gets the blobs associated with the entry with the givenkey
.Returns
null
if entry does not exist.- Specified by:
getBlobs
in interfaceTransientStore
- Specified by:
getBlobs
in classAbstractTransientStore
-
getSize
public long getSize(String key)
Description copied from interface:TransientStore
Returns the size of the blobs associated with the entry with the givenkey
or-1
if entry does not exist.- Specified by:
getSize
in interfaceTransientStore
- Specified by:
getSize
in classAbstractTransientStore
-
isCompleted
public boolean isCompleted(String key)
Description copied from interface:TransientStore
Returnstrue
if the entry with the givenkey
is ready.- Specified by:
isCompleted
in interfaceTransientStore
- Specified by:
isCompleted
in classAbstractTransientStore
-
setCompleted
public void setCompleted(String key, boolean completed)
Description copied from interface:TransientStore
Marks the entry with the givenkey
as ready.If entry does not exist a new entry is created.
- Specified by:
setCompleted
in interfaceTransientStore
- Specified by:
setCompleted
in classAbstractTransientStore
-
release
public void release(String key)
Description copied from interface:TransientStore
Informs the store that the entry with the givenkey
can be released if TTL or GC parameters require to do some cleanup.Has no effect if entry does not exist.
- Specified by:
release
in interfaceTransientStore
- Specified by:
release
in classAbstractTransientStore
-
persistBlobs
protected void persistBlobs(String key, long sizeOfBlobs, List<Map<String,String>> blobInfos)
Description copied from class:AbstractTransientStore
Updates the total storage size and the storage size of the entry with the givenkey
according tosizeOfBlobs
and stores the blob information in this entry.- Specified by:
persistBlobs
in classAbstractTransientStore
-
getStorageSize
public long getStorageSize()
Description copied from interface:TransientStoreProvider
Returns the size (in bytes) of the disk storage used for blobs.- Returns:
- the number of bytes used by stored blobs
-
setStorageSize
protected void setStorageSize(long newSize)
Description copied from class:AbstractTransientStore
Sets the size of the disk storage in bytes.- Specified by:
setStorageSize
in classAbstractTransientStore
-
incrementStorageSize
protected long incrementStorageSize(long size)
- Specified by:
incrementStorageSize
in classAbstractTransientStore
-
decrementStorageSize
protected long decrementStorageSize(long size)
- Specified by:
decrementStorageSize
in classAbstractTransientStore
-
removeEntry
protected void removeEntry(String key)
- Specified by:
removeEntry
in classAbstractTransientStore
-
removeAllEntries
protected void removeAllEntries()
- Specified by:
removeAllEntries
in classAbstractTransientStore
-
getTTL
public long getTTL(String key)
-
getBytes
protected byte[] getBytes(String key)
-
getString
protected String getString(byte[] bytes)
-
serialize
protected byte[] serialize(Serializable value)
-
deserialize
protected Serializable deserialize(byte[] bytes)
-
serialize
protected Map<byte[],byte[]> serialize(Map<String,Serializable> map)
-
deserialize
protected Map<String,Serializable> deserialize(Map<byte[],byte[]> byteMap)
-
setTTL
protected void setTTL(String key, int seconds)
-
-