K - 主键类型(Primary or Unique)B - 数据库记录对象类型(Java Bean)public abstract class BaseTableLoadCaching<K,B extends BaseBean<B>> extends java.lang.Object implements ITableCache<K,B>
LoadingCache实现表数据缓存,并可以通过TableListener实现缓存数据自动更新ITableCache.ImmutableEntry<K,V>, ITableCache.UpdateStrategy| 限定符和类型 | 字段和说明 |
|---|---|
protected java.util.concurrent.ConcurrentMap<K,B> |
cacheMap |
protected TableListener.Adapter<B> |
tableListener |
DEFAULT_CACHE_MAXIMUMSIZE, DEFAULT_DURATION, DEFAULT_STRATEGY, DEFAULT_TIME_UNIT| 构造器和说明 |
|---|
BaseTableLoadCaching() |
BaseTableLoadCaching(ITableCache.UpdateStrategy updateStrategy,
long maximumSize,
long duration,
java.util.concurrent.TimeUnit unit)
构造函数
|
BaseTableLoadCaching(long maximumSize) |
BaseTableLoadCaching(long maximumSize,
long durationMinutes) |
BaseTableLoadCaching(long maximumSize,
long duration,
java.util.concurrent.TimeUnit unit) |
| 限定符和类型 | 方法和说明 |
|---|---|
B |
getBean(K key)
加载主键(key)指定的记录,如果缓存中没有则从数据库中查询
数据库中没有找到则抛出异常 |
B |
getBeanIfPresent(K key)
返回cache中
key指定的记录,如果不存在就返回null |
B |
getBeanUnchecked(K key)
加载主键(key)指定的记录,如果缓存中没有则从数据库中查询
数据库中没有找到则返回 null |
java.util.concurrent.ConcurrentMap<K,B> |
getCacheMap() |
ITableCache.UpdateStrategy |
getUpdateStrategy() |
protected abstract B |
loadfromDatabase(K key)
从数据库中加载主键(pk)指定的记录
|
void |
remove(B bean)
删除cache中
key指定的记录 |
protected abstract K |
returnKey(B bean)
返回bean中主键值
|
void |
update(B bean)
根据当前更新策略(
UpdateStrategy)将bean更新到缓存 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitregisterListener, unregisterListenerprotected final TableListener.Adapter<B extends BaseBean<B>> tableListener
public BaseTableLoadCaching()
public BaseTableLoadCaching(long maximumSize)
public BaseTableLoadCaching(long maximumSize, long durationMinutes)
public BaseTableLoadCaching(long maximumSize, long duration, java.util.concurrent.TimeUnit unit)
public BaseTableLoadCaching(ITableCache.UpdateStrategy updateStrategy, long maximumSize, long duration, java.util.concurrent.TimeUnit unit)
updateStrategy - 缓存更新策略maximumSize - 最大缓存容量,参见 CacheBuilder.maximumSize(long)duration - 失效时间,参见 CacheBuilder.expireAfterWrite(long, TimeUnit)unit - duration的时间单位protected abstract B loadfromDatabase(K key) throws java.lang.Exception
key - primary keyjava.lang.Exceptionpublic B getBean(K key) throws java.util.concurrent.ExecutionException
ITableCachepublic B getBeanIfPresent(K key)
ITableCachekey指定的记录,如果不存在就返回nullgetBeanIfPresent 在接口中 ITableCache<K,B extends BaseBean<B>>Cache.getIfPresent(Object)public B getBeanUnchecked(K key)
ITableCachenullgetBeanUnchecked 在接口中 ITableCache<K,B extends BaseBean<B>>LoadingCache.getUnchecked(Object)public void remove(B bean)
ITableCachekey指定的记录public void update(B bean)
UpdateStrategy)将bean更新到缓存update 在接口中 ITableCache<K,B extends BaseBean<B>>ITableCache.update(net.gdface.facelog.db.BaseBean)public ITableCache.UpdateStrategy getUpdateStrategy()
public java.util.concurrent.ConcurrentMap<K,B> getCacheMap()
Copyright © 2019. All Rights Reserved.