public class RedissonLiveObjectService extends Object implements RLiveObjectService
Constructor and Description |
---|
RedissonLiveObjectService(ConcurrentMap<Class<?>,Class<?>> classCache,
ConnectionManager connectionManager) |
Modifier and Type | Method and Description |
---|---|
<T> RLiveObject |
asLiveObject(T instance)
To cast the instance to RLiveObject instance.
|
<T,K,V> RMap<K,V> |
asRMap(T instance)
To cast the instance to RMap instance.
|
<T> T |
attach(T detachedObject)
Returns proxied object for the detached object.
|
long |
count(Class<?> entityClass,
Condition condition)
Counts the entities matches specified
condition . |
<T> T |
createLiveObject(Class<T> entityClass,
Object id) |
<T> long |
delete(Class<T> entityClass,
Object... ids)
Deletes object by class and ids including all nested objects.
|
RFuture<Long> |
delete(Object id,
Class<?> entityClass,
NamingScheme namingScheme,
CommandBatchService ce) |
<T> void |
delete(T attachedObject)
Deletes attached object including all nested objects.
|
<T> T |
detach(T attachedObject)
Returns unproxied detached object for the attached object.
|
<T> Collection<T> |
find(Class<T> entityClass,
Condition condition)
Finds the entities matches specified
condition . |
<K> Iterable<K> |
findIds(Class<?> entityClass)
Returns iterator for all entry ids by specified
entityClass . |
<K> Iterable<K> |
findIds(Class<?> entityClass,
int count)
Returns iterator for all entry ids by specified
entityClass . |
<T> T |
get(Class<T> entityClass,
Object id)
Finds the entity from Redis with the id.
|
boolean |
isClassRegistered(Class<?> cls)
Check if the class is registered in the cache.
|
<T> boolean |
isExists(T instance)
Returns true if the RLiveObject already exists in redis.
|
<T> boolean |
isLiveObject(T instance)
Returns true if the instance is a instance of RLiveObject.
|
<T> T |
merge(T detachedObject)
Returns proxied object for the detached object.
|
<T> List<T> |
persist(T... detachedObjects)
Returns proxied attached objects for the detached objects.
|
<T> T |
persist(T detachedObject)
Returns proxied attached object for the detached object.
|
void |
registerClass(Class<?> cls)
Pre register the class with the service, registering all the classes on
startup can speed up the instance creation.
|
void |
unregisterClass(Class<?> cls)
Unregister the class with the service.
|
public RedissonLiveObjectService(ConcurrentMap<Class<?>,Class<?>> classCache, ConnectionManager connectionManager)
public <T> T get(Class<T> entityClass, Object id)
RLiveObjectService
get
in interface RLiveObjectService
T
- Entity typeentityClass
- - entity classid
- identifierpublic <T> Collection<T> find(Class<T> entityClass, Condition condition)
RLiveObjectService
condition
.
Usage example:
Collection objects = liveObjectService.find(MyObject.class, Conditions.or(Conditions.in("field", "value1", "value2"), Conditions.and(Conditions.eq("field2", "value2"), Conditions.eq("field3", "value5"))));
find
in interface RLiveObjectService
T
- Entity typeentityClass
- - entity classcondition
- - condition objectConditions
public long count(Class<?> entityClass, Condition condition)
RLiveObjectService
condition
.
Usage example:
long objectsAmount = liveObjectService.count(MyObject.class, Conditions.or(Conditions.in("field", "value1", "value2"), Conditions.and(Conditions.eq("field2", "value2"), Conditions.eq("field3", "value5"))));
count
in interface RLiveObjectService
entityClass
- - entity classcondition
- - condition objectConditions
public <T> T attach(T detachedObject)
RLiveObjectService
attach
in interface RLiveObjectService
T
- Entity typedetachedObject
- - not proxied objectpublic <T> T merge(T detachedObject)
RLiveObjectService
merge
in interface RLiveObjectService
T
- Entity typedetachedObject
- - not proxied objectpublic <T> T persist(T detachedObject)
RLiveObjectService
persist
in interface RLiveObjectService
T
- Entity typedetachedObject
- - not proxied objectpublic <T> List<T> persist(T... detachedObjects)
RLiveObjectService
persist
in interface RLiveObjectService
T
- Entity typedetachedObjects
- - not proxied objectspublic <T> T detach(T attachedObject)
RLiveObjectService
detach
in interface RLiveObjectService
T
- Entity typeattachedObject
- - proxied objectpublic <T> void delete(T attachedObject)
RLiveObjectService
delete
in interface RLiveObjectService
T
- Entity typeattachedObject
- - proxied objectpublic <T> long delete(Class<T> entityClass, Object... ids)
RLiveObjectService
delete
in interface RLiveObjectService
T
- Entity typeentityClass
- - object classids
- - object idspublic RFuture<Long> delete(Object id, Class<?> entityClass, NamingScheme namingScheme, CommandBatchService ce)
public <K> Iterable<K> findIds(Class<?> entityClass)
RLiveObjectService
entityClass
.
Ids traversed with SCAN operation. Each SCAN operation loads
up to count
keys per request.findIds
in interface RLiveObjectService
K
- Key typeentityClass
- - entity classpublic <K> Iterable<K> findIds(Class<?> entityClass, int count)
RLiveObjectService
entityClass
.
Ids traversed with SCAN operation. Each SCAN operation loads
up to count
keys per request.findIds
in interface RLiveObjectService
K
- Key typeentityClass
- - entity classcount
- - keys loaded per request to Redispublic <T> RLiveObject asLiveObject(T instance)
RLiveObjectService
asLiveObject
in interface RLiveObjectService
T
- type of instanceinstance
- - live objectpublic <T,K,V> RMap<K,V> asRMap(T instance)
RLiveObjectService
asRMap
in interface RLiveObjectService
T
- type of instanceK
- type of keyV
- type of valueinstance
- - live objectpublic <T> boolean isLiveObject(T instance)
RLiveObjectService
isLiveObject
in interface RLiveObjectService
T
- type of instanceinstance
- - live objecttrue
object is RLiveObjectpublic <T> boolean isExists(T instance)
RLiveObjectService
isExists
in interface RLiveObjectService
T
- type of instanceinstance
- - live objecttrue
object existspublic void registerClass(Class<?> cls)
RLiveObjectService
registerClass
in interface RLiveObjectService
cls
- - classpublic void unregisterClass(Class<?> cls)
RLiveObjectService
unregisterClass
in interface RLiveObjectService
cls
- It can be either the proxied class or the unproxied conterpart.public boolean isClassRegistered(Class<?> cls)
RLiveObjectService
isClassRegistered
in interface RLiveObjectService
cls
- - type of instancetrue
if class already registeredCopyright © 2014–2020 Redisson. All rights reserved.