Package cn.com.anysdk.redis.impl
Class AbstractRedisServiceImpl
java.lang.Object
cn.com.anysdk.redis.impl.AbstractRedisServiceImpl
- All Implemented Interfaces:
IRedisService
- Direct Known Subclasses:
AliyunRedisServiceImpl,LocalRedisServiceImpl
Redis服务抽象基类
包含所有通用的Redis操作实现
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RedisConnectionFactoryprotected RedisEventManagerprotected RedisExceptionHandlerprotected redis.clients.jedis.Jedisprotected redis.clients.jedis.Pipelineprotected RedisConfigPropertiesprotected redis.clients.jedis.Transaction -
Constructor Summary
ConstructorsConstructorDescriptionAbstractRedisServiceImpl(RedisConfigProperties redisProperties, RedisEventManager eventManager) 构造函数 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanvoiddestroy()voiddiscard()voidexec()protected <T> TexecuteCommand(Function<redis.clients.jedis.Jedis, T> operation) 执行Redis命令并处理异常booleanlongbooleanflushAll()booleanflushDB()protected redis.clients.jedis.JedisgetJedis()获取Jedis连接protected abstract String获取服务名称(用于日志)longbooleanlongbooleanvoidinit()初始化Redis服务longlonglongbooleanlongmemoryUsage(String key) voidmulti()protected abstract voidonInit()子类可重写的初始化方法booleanping()voidpipeline()longlonglongbooleanbooleanbooleanlongvoidsync()longlonglongzRangeByScore(String key, double min, double max) longzRevRangeByScore(String key, double max, double min) double
-
Field Details
-
redisProperties
-
eventManager
-
connectionFactory
-
exceptionHandler
-
jedis
protected redis.clients.jedis.Jedis jedis -
pipeline
protected redis.clients.jedis.Pipeline pipeline -
transaction
protected redis.clients.jedis.Transaction transaction
-
-
Constructor Details
-
AbstractRedisServiceImpl
public AbstractRedisServiceImpl(RedisConfigProperties redisProperties, RedisEventManager eventManager) 构造函数
-
-
Method Details
-
init
@PostConstruct public void init()初始化Redis服务 -
onInit
protected abstract void onInit()子类可重写的初始化方法 -
getServiceName
获取服务名称(用于日志) -
getJedis
protected redis.clients.jedis.Jedis getJedis()获取Jedis连接 -
executeCommand
执行Redis命令并处理异常 -
set
- Specified by:
setin interfaceIRedisService
-
setEx
- Specified by:
setExin interfaceIRedisService
-
get
- Specified by:
getin interfaceIRedisService
-
del
- Specified by:
delin interfaceIRedisService
-
exists
- Specified by:
existsin interfaceIRedisService
-
expire
- Specified by:
expirein interfaceIRedisService
-
ttl
- Specified by:
ttlin interfaceIRedisService
-
hSet
- Specified by:
hSetin interfaceIRedisService
-
hGet
- Specified by:
hGetin interfaceIRedisService
-
hGetAll
- Specified by:
hGetAllin interfaceIRedisService
-
hDel
- Specified by:
hDelin interfaceIRedisService
-
hExists
- Specified by:
hExistsin interfaceIRedisService
-
hLen
- Specified by:
hLenin interfaceIRedisService
-
hKeys
- Specified by:
hKeysin interfaceIRedisService
-
hVals
- Specified by:
hValsin interfaceIRedisService
-
lPush
- Specified by:
lPushin interfaceIRedisService
-
rPush
- Specified by:
rPushin interfaceIRedisService
-
lPop
- Specified by:
lPopin interfaceIRedisService
-
rPop
- Specified by:
rPopin interfaceIRedisService
-
lLen
- Specified by:
lLenin interfaceIRedisService
-
lRange
- Specified by:
lRangein interfaceIRedisService
-
lIndex
- Specified by:
lIndexin interfaceIRedisService
-
lSet
- Specified by:
lSetin interfaceIRedisService
-
lRem
- Specified by:
lRemin interfaceIRedisService
-
sAdd
- Specified by:
sAddin interfaceIRedisService
-
sRem
- Specified by:
sRemin interfaceIRedisService
-
sIsMember
- Specified by:
sIsMemberin interfaceIRedisService
-
sMembers
- Specified by:
sMembersin interfaceIRedisService
-
sCard
- Specified by:
sCardin interfaceIRedisService
-
sInter
- Specified by:
sInterin interfaceIRedisService
-
sUnion
- Specified by:
sUnionin interfaceIRedisService
-
sDiff
- Specified by:
sDiffin interfaceIRedisService
-
zAdd
- Specified by:
zAddin interfaceIRedisService
-
zRem
- Specified by:
zRemin interfaceIRedisService
-
zScore
- Specified by:
zScorein interfaceIRedisService
-
zCard
- Specified by:
zCardin interfaceIRedisService
-
zRange
- Specified by:
zRangein interfaceIRedisService
-
zRevRange
- Specified by:
zRevRangein interfaceIRedisService
-
zRangeByScore
- Specified by:
zRangeByScorein interfaceIRedisService
-
zRevRangeByScore
- Specified by:
zRevRangeByScorein interfaceIRedisService
-
multi
public void multi()- Specified by:
multiin interfaceIRedisService
-
exec
public void exec()- Specified by:
execin interfaceIRedisService
-
discard
public void discard()- Specified by:
discardin interfaceIRedisService
-
pipeline
public void pipeline()- Specified by:
pipelinein interfaceIRedisService
-
sync
public void sync()- Specified by:
syncin interfaceIRedisService
-
eval
- Specified by:
evalin interfaceIRedisService
-
ping
public boolean ping()- Specified by:
pingin interfaceIRedisService
-
close
public void close()- Specified by:
closein interfaceIRedisService
-
keys
- Specified by:
keysin interfaceIRedisService
-
type
- Specified by:
typein interfaceIRedisService
-
memoryUsage
- Specified by:
memoryUsagein interfaceIRedisService
-
flushAll
public boolean flushAll()- Specified by:
flushAllin interfaceIRedisService
-
flushDB
public boolean flushDB()- Specified by:
flushDBin interfaceIRedisService
-
destroy
@PreDestroy public void destroy()
-