public class RedisStore extends Object implements KeyValueStore
Constructor and Description |
---|
RedisStore(String storeName,
redis.clients.jedis.JedisPool pool,
String redisNamespace)
Build a connection to a Redis provider.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the store.
|
String |
get(String key)
Get the value for a key from store.
|
boolean |
isHealthy()
Get the health status of the store.
|
boolean |
isOpen()
Get the open / closed status of the store.
|
void |
open()
Open the store.
|
String |
put(String key,
String value)
Set a value for the key.
|
Map<String,String> |
putAll(Map<String,String> entries)
Set a multiple key/value pairs.
|
String |
remove(String key)
Remove a key from store.
|
void |
removeAllKeys()
Remove all keys associated with the store.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOrDefault, replaceStore
public RedisStore(String storeName, redis.clients.jedis.JedisPool pool, String redisNamespace)
storeName
- The second part of the prefix to keyspace names for this storepool
- A pool of Jedis connection instancesredisNamespace
- The first part of the prefix to the keyspace names for this storepublic void open()
KeyValueStore
open
in interface KeyValueStore
public void close()
KeyValueStore
close
in interface KeyValueStore
close
in interface Closeable
close
in interface AutoCloseable
public boolean isOpen()
KeyValueStore
isOpen
in interface KeyValueStore
public void removeAllKeys()
This is mainly used for tests; the Redis command used to get the associated keys (KEYS) is rather expensive and shouldn't be run frequently.
public String remove(@NotNull String key)
KeyValueStore
remove
in interface KeyValueStore
key
- Key to removepublic String get(@NotNull String key)
KeyValueStore
get
in interface KeyValueStore
key
- Key to get the value forpublic boolean isHealthy()
KeyValueStore
isHealthy
in interface KeyValueStore
public String put(@NotNull String key, String value)
KeyValueStore
Also removes the key if the value is null.
put
in interface KeyValueStore
key
- Key to setvalue
- Value to set for the given keypublic Map<String,String> putAll(@NotNull Map<String,String> entries)
KeyValueStore
Removes any keys with a null value.
putAll
in interface KeyValueStore
entries
- Map of key/value pairs to putCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.