public class RedisCache<K,V> extends Object implements CacheWithLifetimes<K,V>
| Constructor and Description |
|---|
RedisCache(redis.clients.jedis.Jedis jedisCache,
long defaultLifespan)
Constructor in which already-created Jedis instance is passed in to be used as underlying
cache.
|
RedisCache(String host,
int port,
int timeout,
long defaultLifespan)
Constructor creating Jedis instance
|
RedisCache(String host,
int port,
long defaultLifespan)
Constructor creating Jedis instance
|
RedisCache(String host,
long defaultLifespan)
Constructor creating Jedis instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
delete all key-value pairs from the current database
|
void |
close()
Close a Redis connection
|
void |
delete(K key)
delete a key-value pair from the cache
|
void |
deleteAll(List<K> keys)
delete one or more key-value pairs from the cache
|
String |
flushAll()
delete all key-value pairs from all databases
|
V |
get(K key)
look up a value in the cache
|
Map<K,V> |
getAll(List<K> keys)
look up one or more values in the cache.
|
CacheEntry<V> |
getCacheEntry(K key)
look up a CacheEntry in the cache.
|
RedisCacheStats |
getStatistics()
get cache statistics.
|
String |
printCacheEntry(K key)
Return string representing a cache entry corresponding to a key (or indicate if the
key is not in the cache).
|
void |
put(K key,
V value)
cache a key-value pair
|
void |
put(K key,
V value,
long lifetime)
cache a key-value pair
|
void |
putAll(Map<K,V> map)
cache one or more key-value pairs
|
void |
putAll(Map<K,V> map,
long lifetime)
cache one or more key-value pairs
|
long |
size()
Return number of objects in cache
|
String |
toString()
Output contents of current database to a string.
|
String |
toString(String charset)
Output contents of current database to a string.
|
public RedisCache(String host, long defaultLifespan)
host - host where Redis is runningdefaultLifespan - Default life time in milliseconds for cached objectspublic RedisCache(String host, int port, long defaultLifespan)
host - host where Redis is runningport - port numberdefaultLifespan - Default life time in milliseconds for cached objectspublic RedisCache(String host, int port, int timeout, long defaultLifespan)
host - host where Redis is runningport - port numbertimeout - number of seconds before Jedis closes an idle connectiondefaultLifespan - Default life time in milliseconds for cached objectspublic RedisCache(redis.clients.jedis.Jedis jedisCache,
long defaultLifespan)
jedisCache - Existing Jedis instance to be used as underlying cachedefaultLifespan - Default life time in milliseconds for cached objectspublic void clear()
public void close()
public void delete(K key)
public String flushAll()
public Map<K,V> getAll(List<K> keys)
public CacheEntry<V> getCacheEntry(K key)
getCacheEntry in interface Cache<K,V>key - key corresponding to valuepublic RedisCacheStats getStatistics()
getStatistics in interface Cache<K,V>public String printCacheEntry(K key)
key - key corresponding to valuepublic void put(K key, V value, long lifetime)
put in interface CacheWithLifetimes<K,V>key - key associated with valuevalue - value associated with keylifetime - lifetime in milliseconds associated with datapublic void putAll(Map<K,V> map, long lifetime)
putAll in interface CacheWithLifetimes<K,V>map - map containing key-value pairs to cachelifetime - lifetime in milliseconds associated with each key-value pairpublic long size()
public String toString(String charset)
charset - Character set representing keys, if not defaultCopyright © 2015. All rights reserved.