public class RedisContainer extends Object implements RedisCommandsContainer, Closeable
RedisContainer(JedisPool)
.
If want to connect to a Redis sentinels, Please use the second constructor RedisContainer(JedisSentinelPool)
Constructor and Description |
---|
RedisContainer(redis.clients.jedis.JedisPool jedisPool)
Use this constructor if to connect with single Redis server.
|
RedisContainer(redis.clients.jedis.JedisSentinelPool sentinelPool)
Use this constructor if Redis environment is clustered with sentinels.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the Jedis instances.
|
void |
hset(String key,
String hashField,
String value)
Sets field in the hash stored at key to value.
|
void |
lpush(String listName,
String value)
Insert the specified value at the head of the list stored at key.
|
void |
pfadd(String key,
String element)
Adds all the element arguments to the HyperLogLog data structure
stored at the variable name specified as first argument.
|
void |
publish(String channelName,
String message)
Posts a message to the given channel.
|
void |
rpush(String listName,
String value)
Insert the specified value at the tail of the list stored at key.
|
void |
sadd(String setName,
String value)
Add the specified member to the set stored at key.
|
void |
set(String key,
String value)
Set key to hold the string value.
|
void |
zadd(String key,
String score,
String element)
Adds the specified member with the specified scores to the sorted set stored at key.
|
public RedisContainer(redis.clients.jedis.JedisPool jedisPool)
jedisPool
- JedisPool which actually manages Jedis instancespublic RedisContainer(redis.clients.jedis.JedisSentinelPool sentinelPool)
sentinelPool
- SentinelPool which actually manages Jedis instancespublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface RedisCommandsContainer
IOException
- if the instance can not be closed properlypublic void hset(String key, String hashField, String value)
RedisCommandsContainer
hset
in interface RedisCommandsContainer
key
- Hash namehashField
- Hash fieldvalue
- Hash valuepublic void rpush(String listName, String value)
RedisCommandsContainer
rpush
in interface RedisCommandsContainer
listName
- Name of the Listvalue
- Value to be addedpublic void lpush(String listName, String value)
RedisCommandsContainer
lpush
in interface RedisCommandsContainer
listName
- Name of the Listvalue
- Value to be addedpublic void sadd(String setName, String value)
RedisCommandsContainer
sadd
in interface RedisCommandsContainer
setName
- Name of the Setvalue
- Value to be addedpublic void publish(String channelName, String message)
RedisCommandsContainer
publish
in interface RedisCommandsContainer
channelName
- Name of the channel to which data will be publishedmessage
- the messagepublic void set(String key, String value)
RedisCommandsContainer
set
in interface RedisCommandsContainer
key
- the key name in which value to be setvalue
- the valuepublic void pfadd(String key, String element)
RedisCommandsContainer
pfadd
in interface RedisCommandsContainer
key
- The name of the keyelement
- the elementpublic void zadd(String key, String score, String element)
RedisCommandsContainer
zadd
in interface RedisCommandsContainer
key
- The name of the Sorted Setscore
- Score of the elementelement
- element to be addedCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.