public class RedisClassDescriptorStorage extends ClassDescriptorStorage
Implementation of ClassDescriptorStorage used by aredis that stores the ClassDescriptors on a redis server. The data is serialized using java serialization and saved under the specified key. The default key is JAVA_CL_DESCRIPTORS. The key is non-volatile.
Note that aredis uses this class via PerConnectionRedisClassDescriptorStorageFactory
which is the default
or RedisClassDescriptorStorageFactory
.
The updateClassDescriptors method uses WATCH-MULTI-EXEC commands along with checking of versionNo to avoid dirty update.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DESCRIPTORS_KEY
Constant for the default key in which to store the Class Descriptors.
|
Constructor and Description |
---|
RedisClassDescriptorStorage(AsyncRedisConnection paredis)
Creates a storage for the given Redis Connection with the defalt key "JAVA_CL_DESCRIPTORS".
|
RedisClassDescriptorStorage(AsyncRedisConnection paredis,
String pdescriptorsKey,
int pdbIndex)
Creates a storage for the given Redis Connection and descriptors key.
|
Modifier and Type | Method and Description |
---|---|
ClassDescriptors |
getMasterClassDescriptors(boolean refreshFromStore)
Gets the class descriptors from the store.
|
boolean |
updateClassDescriptors(ClassDescriptors updatedDescriptors)
Updates the class descriptors based on optimistic locking (Dirty write check) similar to WATCH-MULTI-EXEC or
in redis or CAS in memcached.
|
getCleanupAgeDays, getUseTimeUpdateInterval, setCleanupAgeDays, setUseTimeUpdateInterval, updateTimingsAndCleanup
public static final String DEFAULT_DESCRIPTORS_KEY
public RedisClassDescriptorStorage(AsyncRedisConnection paredis, String pdescriptorsKey, int pdbIndex)
paredis
- Async Redis Connection to UsepdescriptorsKey
- Key in which to store the DescriptorspdbIndex
- The dbIndex to use. This could be different from that in aredispublic RedisClassDescriptorStorage(AsyncRedisConnection paredis)
paredis
- Async Redis Connection to Usepublic ClassDescriptors getMasterClassDescriptors(boolean refreshFromStore) throws IOException
ClassDescriptorStorage
getMasterClassDescriptors
in class ClassDescriptorStorage
refreshFromStore
- Whether to fetch the Class Descriptors from store even if a local copy is availableIOException
- In case of error fetching the ClassDescriptorspublic boolean updateClassDescriptors(ClassDescriptors updatedDescriptors) throws IOException
ClassDescriptorStorage
updateClassDescriptors
in class ClassDescriptorStorage
updatedDescriptors
- Updated Class DescriptorsIOException
- In case there is an error updating the ClassDescriptorsCopyright © 2013- Suresh Mahalingam. All Rights Reserved.