public class JedisUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected static org.slf4j.Logger |
logger |
| 构造器和说明 |
|---|
JedisUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
del(String key)
删除缓存
|
static long |
delObject(String key)
删除缓存
|
static boolean |
exists(String key)
缓存是否存在
|
static boolean |
existsObject(String key)
缓存是否存在
|
static String |
expire(String key,
int cacheSeconds)
重新设置过期时间
|
static String |
get(String key)
获取缓存
|
static byte[] |
getBytesKey(Object object)
获取byte[]类型Key
|
static Set<String> |
getKeysByPrefix(String keyPrefix)
描述:获取以指定开头前缀的所有Key
|
static List<String> |
getList(String key)
获取List缓存
|
static Map<String,String> |
getMap(String key)
获取Map缓存
|
static Object |
getObject(String key)
获取缓存
|
static Object |
getObjectKey(byte[] key)
获取byte[]类型Key
|
static List<Object> |
getObjectList(String key)
获取List缓存
|
static List<Object> |
getObjectListByKeyPrefix(String keyPrefix)
描述:根据key前缀模糊查询缓存对象
|
static Map<String,Object> |
getObjectMap(String key)
获取Map缓存
|
static Set<Object> |
getObjectSet(String key)
获取缓存
|
static redis.clients.jedis.JedisPool |
getPool() |
static redis.clients.jedis.Jedis |
getResource()
获取资源
|
static Set<String> |
getSet(String key)
获取缓存
|
static void |
init() |
static boolean |
isBlank(String str) |
static Set<String> |
keys(String pattern)
key筛选
|
static long |
listAdd(String key,
String... value)
向List缓存中添加值
|
static long |
listObjectAdd(String key,
Object... value)
向List缓存中添加值
|
static void |
main(String[] args) |
static boolean |
mapExists(String key,
String mapKey)
判断Map缓存中的Key是否存在
|
static boolean |
mapObjectExists(String key,
String mapKey)
判断Map缓存中的Key是否存在
|
static String |
mapObjectPut(String key,
Map<String,Object> value)
向Map缓存中添加值
|
static long |
mapObjectRemove(String key,
String mapKey)
移除Map缓存中的值
|
static String |
mapPut(String key,
Map<String,String> value)
向Map缓存中添加值
|
static long |
mapRemove(String key,
String mapKey)
移除Map缓存中的值
|
static void |
returnBrokenResource(redis.clients.jedis.Jedis jedis)
归还资源
|
static void |
returnResource(redis.clients.jedis.Jedis jedis)
释放资源
|
static byte[] |
serialize(Object object)
序列化对象
|
static String |
set(String key,
String value,
int cacheSeconds)
设置缓存
|
static long |
setList(String key,
List<String> value,
int cacheSeconds)
设置List缓存
|
static String |
setMap(String key,
Map<String,String> value,
int cacheSeconds)
设置Map缓存
|
static String |
setObject(String key,
Object value,
int cacheSeconds)
设置缓存
|
static long |
setObjectList(String key,
List<Object> value,
int cacheSeconds)
设置List缓存
|
static String |
setObjectMap(String key,
Map<String,Object> value,
int cacheSeconds)
设置Map缓存
|
static long |
setObjectSet(String key,
Set<Object> value,
int cacheSeconds)
设置Set缓存
|
static long |
setSet(String key,
Set<String> value,
int cacheSeconds)
设置Set缓存
|
static long |
setSetAdd(String key,
String... value)
向Set缓存中添加值
|
static long |
setSetObjectAdd(String key,
Object... value)
向Set缓存中添加值
|
static byte[] |
toBytes(Object object)
Object转换byte[]类型
|
static Object |
toObject(byte[] bytes)
byte[]型转换Object
|
static Object |
unserialize(byte[] bytes)
反序列化对象
|
static Long |
zadd(String key,
long score,
String member) |
static Set<redis.clients.jedis.Tuple> |
zrangeWithScores(String key,
int start,
int end) |
public static void init()
public static void main(String[] args)
public static redis.clients.jedis.JedisPool getPool()
public static String set(String key, String value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static String expire(String key, int cacheSeconds)
key - cacheSeconds - public static String setObject(String key, Object value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static Set<redis.clients.jedis.Tuple> zrangeWithScores(String key, int start, int end)
public static List<Object> getObjectListByKeyPrefix(String keyPrefix)
keyPrefix - public static long setList(String key, List<String> value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static long setObjectList(String key, List<Object> value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static long listAdd(String key, String... value)
key - 键value - 值public static long listObjectAdd(String key, Object... value)
key - 键value - 值public static Set<String> getKeysByPrefix(String keyPrefix)
keyPrefix - public static long setSet(String key, Set<String> value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static long setObjectSet(String key, Set<Object> value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static long setSetAdd(String key, String... value)
key - 键value - 值public static long setSetObjectAdd(String key, Object... value)
key - 键value - 值public static String setMap(String key, Map<String,String> value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static String setObjectMap(String key, Map<String,Object> value, int cacheSeconds)
key - 键value - 值cacheSeconds - 超时时间,0为不超时public static String mapPut(String key, Map<String,String> value)
key - 键value - 值public static String mapObjectPut(String key, Map<String,Object> value)
key - 键value - 值public static long mapRemove(String key, String mapKey)
key - 键mapKey - 值public static long mapObjectRemove(String key, String mapKey)
key - 键mapKey - 值public static boolean mapExists(String key, String mapKey)
key - 键mapKey - 值public static boolean mapObjectExists(String key, String mapKey)
key - 键mapKey - 值public static long del(String key)
key - 键public static long delObject(String key)
key - 键public static boolean exists(String key)
key - 键public static boolean existsObject(String key)
key - 键public static redis.clients.jedis.Jedis getResource()
throws redis.clients.jedis.exceptions.JedisException
redis.clients.jedis.exceptions.JedisExceptionpublic static void returnBrokenResource(redis.clients.jedis.Jedis jedis)
jedis - public static void returnResource(redis.clients.jedis.Jedis jedis)
jedis - public static byte[] getBytesKey(Object object)
object - public static Object getObjectKey(byte[] key)
key - public static boolean isBlank(String str)
public static byte[] toBytes(Object object)
object - public static Object toObject(byte[] bytes)
bytes - public static byte[] serialize(Object object)
object - public static Object unserialize(byte[] bytes)
bytes - Copyright © 2022. All rights reserved.