public class CacheableLookupDao<T> extends LookupDao<T>
LookupKey
The entity can be retrieved from any shard using the key.LookupDao.ReadOnlyContext<T>| Constructor and Description |
|---|
CacheableLookupDao(List<org.hibernate.SessionFactory> sessionFactories,
Class<T> entityClass,
ShardCalculator<String> shardCalculator,
LookupCache<T> cache,
ShardingBundleOptions shardingOptions,
ShardInfoProvider shardInfoProvider,
TransactionObserver observer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
exists(String key)
Read through exists check on the basis of key (value of field annotated with
LookupKey) from cache. |
Optional<T> |
get(String key)
Read through an object on the basis of key (value of field annotated with
LookupKey) from cache. |
Optional<T> |
save(T entity)
Write through the entity on proper shard based on hash of the value in the key field in the object and into cache.
|
boolean |
update(String id,
Function<Optional<T>,T> updater)
Update the entity with a given id and refresh the object in the cache.
|
count, createOrUpdate, delete, get, get, get, get, getKeyField, lockAndGetExecutor, readOnlyExecutor, readOnlyExecutor, readOnlyExecutor, readOnlyExecutor, run, run, runInSession, runInSession, save, saveAndGetExecutor, scatterGather, scrollDown, scrollUp, updateInLock, updateUsingQueryclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetShardCalculatorpublic CacheableLookupDao(List<org.hibernate.SessionFactory> sessionFactories, Class<T> entityClass, ShardCalculator<String> shardCalculator, LookupCache<T> cache, ShardingBundleOptions shardingOptions, ShardInfoProvider shardInfoProvider, TransactionObserver observer)
public Optional<T> get(String key) throws Exception
LookupKey) from cache.
Cache miss will be delegated to LookupDao.get(String) method.
Note: Lazy loading will not work once the object is returned.
If you need lazy loading functionality use the alternate LookupDao.get(String, Function) method.public Optional<T> save(T entity) throws Exception
public boolean update(String id, Function<Optional<T>,T> updater)
LookupDao.update(String, Function) method.public boolean exists(String key) throws Exception
LookupKey) from cache.
Cache miss will be delegated to LookupDao.exists(String) method.Copyright © 2016–2023. All rights reserved.