public class RedisMap<K,V> extends Object implements ICacheMap<K,V>, Closeable
Modifier and Type | Class and Description |
---|---|
class |
RedisMap.RedisMapEntry<K,V> |
Modifier and Type | Field and Description |
---|---|
static String |
LOCK_SUCCESS |
static String |
SET_EXPIRE_TIME |
static String |
SET_NOT_EXIST |
static Long |
UNLOCK_SUCCESS |
Constructor and Description |
---|
RedisMap()
构造函数
如果 name 为 null,则采用 redis 的顶层键值系统
|
RedisMap(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
构造函数
|
RedisMap(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool,
String name)
构造函数
|
RedisMap(String name)
构造函数
|
RedisMap(String host,
int port,
int timeout,
int poolsize)
构造函数
如果 name 为 null,则采用 redis 的顶层键值系统
|
RedisMap(String host,
int port,
int timeout,
int poolsize,
String name)
构造函数
|
RedisMap(String host,
int port,
int timeout,
int poolsize,
String name,
String password)
构造函数
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
close() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
RedisMap<K,V> |
dbIndex(int dbIndex)
选择当前数据集
|
Set<Map.Entry<K,V>> |
entrySet() |
RedisMap<K,V> |
expire(long expire)
设置超时时间
|
V |
get(Object key,
Function<K,V> appointedSupplier,
Long createExpire,
boolean refresh)
获取对象
|
int |
getDbIndex()
获取当前选择的数据集
|
long |
getExpire()
获取超时时间
|
Function<K,V> |
getSupplier()
获取数据创建 Function 对象
|
long |
getTTL(K key)
为 Key 获取 key 的超时时间
|
long |
incr(K key,
long value)
原子增加操作
|
double |
incrFloat(K key,
double value)
原子增加操作
|
boolean |
isEmpty() |
Set<K> |
keySet() |
Set<K> |
keySet(String pattern)
获取键集合
|
boolean |
persist(K key)
持久化某个
|
V |
put(K key,
V value) |
V |
put(K key,
V value,
long expire)
像 redis 中放置字符串数据
|
void |
putAll(Map<? extends K,? extends V> map) |
void |
putAll(Map<? extends K,? extends V> map,
long expire) |
V |
putIfAbsent(K key,
V value)
在 Redis 环境下返回的数据不保证是 Redis 中的数据
|
V |
putIfAbsent(K key,
V value,
long expire) |
V |
remove(Object key) |
ScanedObject |
scan(String cursor,
V matchValue,
Integer count) |
boolean |
setTTL(K key,
long expire)
更新某个对象的超时时间
可以为某个没有配置超时时间的键值对配置超时时间
|
int |
size() |
RedisMap<K,V> |
supplier(Function<K,V> supplier)
如果参数为空的默认构造方法
|
Collection<V> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, get, get, getAndRefresh, getAndRefresh, getAndRefresh
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, remove, replace, replace, replaceAll
public static final String LOCK_SUCCESS
public static final Long UNLOCK_SUCCESS
public static final String SET_NOT_EXIST
public static final String SET_EXPIRE_TIME
public RedisMap(String host, int port, int timeout, int poolsize, String name, String password)
host
- redis 服务地址port
- redis 服务端口timeout
- redis 连接超时时间poolsize
- redis 连接池的大小name
- 在 redis 中的 HashMap的名称password
- redis 服务密码public RedisMap(String host, int port, int timeout, int poolsize, String name)
host
- redis 服务地址port
- redis 服务端口timeout
- redis 连接超时时间poolsize
- redis 连接池的大小name
- 在 redis 中的 HashMap的名称public RedisMap(String host, int port, int timeout, int poolsize)
host
- redis 服务地址port
- redis 服务端口timeout
- redis 连接超时时间poolsize
- redis 连接池的大小public RedisMap(String name)
name
- 在 redis 中的 HashMap的名称public RedisMap(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool, String name)
jedisPool
- redis 连接池name
- 在 redis 中的 HashMap的名称public RedisMap(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
jedisPool
- redis 连接池public RedisMap()
public int getDbIndex()
public RedisMap<K,V> dbIndex(int dbIndex)
dbIndex
- 数据集序号public Function<K,V> getSupplier()
getSupplier
in interface ICacheMap<K,V>
public long getExpire()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public V get(Object key, Function<K,V> appointedSupplier, Long createExpire, boolean refresh)
public V putIfAbsent(K key, V value)
putIfAbsent
in interface Map<K,V>
key
- 更新的 keyvalue
- 更新的 value,public V putIfAbsent(K key, V value, long expire)
putIfAbsent
in interface ICacheMap<K,V>
public boolean setTTL(K key, long expire)
public long getTTL(K key)
public boolean persist(K key)
key
- key 名称public long incr(K key, long value)
key
- key 名称value
- 值public double incrFloat(K key, double value)
key
- key 名称value
- 值public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public ScanedObject scan(String cursor, V matchValue, Integer count)
Copyright © 2020 Voovan. All rights reserved.