public class RedisString extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected String |
groupName |
protected String |
key |
protected static String |
RESP_OK |
| 构造器和说明 |
|---|
RedisString(String key) |
RedisString(String key,
String groupName) |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
exists()
检查给定 key 是否存在。
|
String |
get() |
Long |
getTtl()
返回给定 key 的剩余生存时间(单位:秒)
|
boolean |
remove()
删除给定的一个 key 。
|
boolean |
removeExpire()
移除给定 key 的生存时间,设置为永久有效
|
RedisString |
resetKey(String key)
重置key(适合一个方法里面频繁操作不同缓存的场景)
非线程安全,请不要在多线程场景使用 |
boolean |
set(String value)
设置缓存,默认过期时间
|
boolean |
set(String value,
Date expireAt)
检查给定 key 是否存在。
|
boolean |
set(String value,
long seconds)
设置缓存指定过期时间间隔
|
boolean |
setExpire(long seconds)
为给定 key 设置生存时间,当 key 过期时(生存时间为 0 ),它会被自动删除。
|
boolean |
setExpireAt(Date expireAt)
设置指定时间戳时失效
注意:redis服务器时间问题
|
public RedisString(String key)
public RedisString resetKey(String key)
key - public boolean set(String value)
value - public boolean set(String value, long seconds)
value - seconds - (过期秒数 ,小于等于0时 不设置)public String get()
public boolean exists()
key - public boolean remove()
key - public boolean setExpire(long seconds)
key - seconds - 超时时间,单位:秒public boolean setExpireAt(Date expireAt)
key - expireAt - 超时时间点public Long getTtl()
key - public boolean removeExpire()
key - Copyright © 2016. All rights reserved.