public class RedisClient extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
| 构造器和说明 |
|---|
RedisClient() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(String key,
Object value)
add if not exists
|
boolean |
add(String key,
Object value,
Integer expiration)
add if not exists
|
void |
afterPropertiesSet() |
boolean |
delete(String key)
Remove the specified keys.
|
protected Object |
deserialize(byte[] in)
Get the object represented by the given serialized bytes.
|
void |
destroy() |
boolean |
exists(String key)
Test if the specified key exists.
|
boolean |
expire(String key,
int seconds)
to add expire time in seconds
|
boolean |
flushall()
Delete all the keys of all the existing databases, not just the currently
selected one.
|
Object |
get(String key)
get value
return null if key did not exist |
String |
getCacheName() |
redis.clients.jedis.JedisPool |
getJedisPool() |
int |
getPort() |
protected org.apache.commons.pool.impl.GenericObjectPool |
getRealPool() |
protected org.apache.commons.pool.impl.GenericObjectPool |
getRealPoolInstance()
获取实际的对象池实例
|
String |
getRedisAuthKey() |
String |
getRedisServer() |
byte |
getWhenExhaustedAction() |
boolean |
hdel(String key,
String field)
delete element from set
|
boolean |
hExists(String key,
String field)
check key exist in set
|
Object |
hget(String key,
String field)
get value by element key from set
|
Map<String,Object> |
hGetAll(String key)
get map value from set
|
Set<String> |
hKeys(String key)
get keys from set
|
long |
hLen(String key)
get size from set
|
List<Object> |
hmGet(String key,
String... fields)
get keys from set
|
void |
hmSet(String key,
Map<String,Serializable> values)
set map value to target set
|
void |
hput(String key,
String field,
Serializable fieldValue)
add value to set
|
List<Object> |
hValues(String key)
get values from set
|
String |
ping()
do ping action
|
protected byte[] |
serialize(Object o)
Get the bytes representing the given serialized object.
|
boolean |
set(String key,
Object value)
set a value without expiration
|
boolean |
set(String key,
Object value,
Integer expiration)
value set
The string can't be longer than 1073741824 bytes (1 GB). |
void |
setCacheName(String cacheName) |
protected void |
setJedisPool(redis.clients.jedis.JedisPool jedisPool) |
void |
setPort(int port) |
protected void |
setRealPool(org.apache.commons.pool.impl.GenericObjectPool realPool) |
void |
setRedisAuthKey(String redisAuthKey) |
void |
setRedisServer(String redisServer) |
void |
setWhenExhaustedAction(byte whenExhaustedAction) |
void |
shutdown()
do destroy jedis pool
|
public void afterPropertiesSet()
throws Exception
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanExceptionprotected org.apache.commons.pool.impl.GenericObjectPool getRealPoolInstance()
public Object get(String key) throws Exception
key - cache keyException - in case of access redis server exceptionpublic String ping() throws Exception
Exception - in case of access redis server exceptionpublic boolean set(String key, Object value, Integer expiration) throws Exception
key - cache keyvalue - valueexpiration - expiration time 超时时间Exception - in case of access redis server exceptionpublic boolean set(String key, Object value) throws Exception
key - cache keyvalue - cache valueException - in case of access redis server exceptionpublic boolean add(String key, Object value, Integer expiration) throws Exception
key - cache keyvalue - cache valueexpiration - expiration timeException - in case of access redis server exceptionpublic boolean add(String key, Object value) throws Exception
key - cache ekyvalue - cache valueException - in case of access redis server exceptionpublic boolean exists(String key) throws Exception
key - cache keyException - in case of access redis server exceptionpublic boolean delete(String key)
key - cache keypublic boolean expire(String key, int seconds)
key - cache keyseconds - expiration in secondspublic boolean flushall()
public void shutdown()
jedisPoolprotected byte[] serialize(Object o)
o - target valueprotected Object deserialize(byte[] in)
in - byte arraypublic void hput(String key, String field, Serializable fieldValue) throws Exception
key - cache key of setfield - element keyfieldValue - valueException - in case of access redis server exceptionpublic Object hget(String key, String field)
key - cache key of setfield - element keypublic boolean hdel(String key, String field) throws Exception
key - cache key of setfield - element keyException - in case of access redis server exceptionpublic Set<String> hKeys(String key) throws Exception
key - cache keyException - in case of access redis server exceptionpublic List<Object> hValues(String key) throws Exception
key - cache keyException - in case of access redis server exceptionpublic boolean hExists(String key, String field) throws Exception
key - cache key of setfield - element keyException - in case of access redis server exceptionpublic long hLen(String key) throws Exception
key - cache keyException - in case of access redis server exceptionpublic Map<String,Object> hGetAll(String key) throws Exception
key - cache keyException - in case of access redis server exceptionpublic void hmSet(String key, Map<String,Serializable> values) throws Exception
key - cache keyvalues - map valueException - in case of access redis server exceptionpublic List<Object> hmGet(String key, String... fields) throws Exception
key - key namefields - key namesException - in case of access redis server exceptionpublic void destroy()
throws Exception
destroy 在接口中 org.springframework.beans.factory.DisposableBeanExceptionpublic redis.clients.jedis.JedisPool getJedisPool()
protected void setJedisPool(redis.clients.jedis.JedisPool jedisPool)
protected void setRealPool(org.apache.commons.pool.impl.GenericObjectPool realPool)
protected org.apache.commons.pool.impl.GenericObjectPool getRealPool()
public String getRedisServer()
public void setRedisServer(String redisServer)
public String getCacheName()
public void setCacheName(String cacheName)
public String getRedisAuthKey()
public void setRedisAuthKey(String redisAuthKey)
public int getPort()
public void setPort(int port)
public byte getWhenExhaustedAction()
public void setWhenExhaustedAction(byte whenExhaustedAction)
Copyright © 2018. All rights reserved.