Class AbstractStampManager<K,V>
java.lang.Object
cn.herodotus.engine.cache.jetcache.stamp.AbstractStampManager<K,V>
- Type Parameters:
K- 签章缓存对应Key值的类型。V- 签章缓存存储数据,对应的具体存储值的类型,
- All Implemented Interfaces:
StampManager<K,,V> org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
AbstractCountStampManager
Description: 抽象Stamp管理
- Author:
- : gengwei.zheng
- Date:
- : 2021/8/23 11:51
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractStampManager(String cacheName) AbstractStampManager(String cacheName, com.alicp.jetcache.anno.CacheType cacheType) AbstractStampManager(String cacheName, com.alicp.jetcache.anno.CacheType cacheType, Duration expire) -
Method Summary
Modifier and TypeMethodDescriptionboolean校验Stamp值,与本地存储的Stamp 是否匹配void删除与Key对应的Stamp根据key读取StampgetCache()指定数据存储缓存过期时间com.alicp.jetcache.AutoReleaseLock锁定值booleanlockAndRun(K key, long expire, TimeUnit timeUnit, Runnable action) 锁定并执行操作void保存与Key对应的Stamp签章值voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.InitializingBean
afterPropertiesSetMethods inherited from interface cn.herodotus.engine.cache.jetcache.stamp.StampManager
containKey, create, create, create, lock, lock, lockAndRun, lockAndRun, nextStamp, put, put
-
Constructor Details
-
AbstractStampManager
-
AbstractStampManager
-
AbstractStampManager
-
-
Method Details
-
getCache
指定数据存储缓存- Returns:
Cache
-
getExpire
Description copied from interface:StampManager过期时间- Specified by:
getExpirein interfaceStampManager<K,V> - Returns:
Duration
-
setExpire
-
check
public boolean check(K key, V value) throws cn.herodotus.engine.cache.core.exception.StampParameterIllegalException, cn.herodotus.engine.cache.core.exception.StampHasExpiredException, cn.herodotus.engine.cache.core.exception.StampMismatchException Description copied from interface:StampManager校验Stamp值,与本地存储的Stamp 是否匹配- Specified by:
checkin interfaceStampManager<K,V> - Parameters:
key- 与Stamp对应的Key值value- 外部传入的Stamp值- Returns:
- ture 匹配,false 不匹配
- Throws:
cn.herodotus.engine.cache.core.exception.StampParameterIllegalException- 传入Stamp错误cn.herodotus.engine.cache.core.exception.StampHasExpiredException- 本地数据中没有Stamp或者Stamp已经过期。cn.herodotus.engine.cache.core.exception.StampMismatchException- Stamp与本地存储值不匹配
-
get
Description copied from interface:StampManager根据key读取Stamp- Specified by:
getin interfaceStampManager<K,V> - Parameters:
key- 存储数据Key值- Returns:
- 存储的Stamp值
-
delete
Description copied from interface:StampManager删除与Key对应的Stamp- Specified by:
deletein interfaceStampManager<K,V> - Parameters:
key- 存储数据Key值
-
put
Description copied from interface:StampManager保存与Key对应的Stamp签章值- Specified by:
putin interfaceStampManager<K,V> - Parameters:
key- 存储Keyvalue- 与Key对应的StampexpireAfterWrite- 过期时间timeUnit- 过期时间单位
-
lock
Description copied from interface:StampManager锁定值非堵塞的尝试获取一个锁,如果对应的key还没有锁,返回一个AutoReleaseLock,否则立即返回空。如果Cache实例是本地的,它是一个本地锁,在本JVM中有效;如果是redis等远程缓存,它是一个不十分严格的分布式锁。锁的超时时间由expire和timeUnit指定。多级缓存的情况会使用最后一级做tryLock操作。
- Specified by:
lockin interfaceStampManager<K,V> - Parameters:
key- 存储Keyexpire- 过期时间timeUnit- 过期时间单位- Returns:
AutoReleaseLock- See Also:
-
lockAndRun
Description copied from interface:StampManager锁定并执行操作非堵塞的尝试获取一个锁,如果对应的key还没有锁,返回一个AutoReleaseLock,否则立即返回空。如果Cache实例是本地的,它是一个本地锁,在本JVM中有效;如果是redis等远程缓存,它是一个不十分严格的分布式锁。锁的超时时间由expire和timeUnit指定。多级缓存的情况会使用最后一级做tryLock操作。
- Specified by:
lockAndRunin interfaceStampManager<K,V> - Parameters:
key- 存储Keyexpire- 过期时间timeUnit- 过期时间单位action- 需要执行的操作Runnable- Returns:
- 是否执行成功
- See Also:
-