public class RedisClient
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private org.jboss.netty.bootstrap.ClientBootstrap |
bootstrap |
private org.jboss.netty.channel.group.ChannelGroup |
channels |
private long |
timeout |
private org.jboss.netty.util.Timer |
timer |
private java.util.concurrent.TimeUnit |
unit |
| Constructor and Description |
|---|
RedisClient(java.lang.String host)
Create a new client that connects to the supplied host on the default port.
|
RedisClient(java.lang.String host,
int port)
Create a new client that connects to the supplied host and port.
|
| Modifier and Type | Method and Description |
|---|---|
RedisConnection<java.lang.String,java.lang.String> |
connect()
Open a new synchronous connection to the redis server that treats
keys and values as UTF-8 strings.
|
private <K,V,T extends RedisAsyncConnection<K,V>> |
connect(CommandHandler<K,V> handler,
T connection) |
<K,V> RedisConnection<K,V> |
connect(RedisCodec<K,V> codec)
Open a new synchronous connection to the redis server.
|
RedisAsyncConnection<java.lang.String,java.lang.String> |
connectAsync()
Open a new asynchronous connection to the redis server that treats
keys and values as UTF-8 strings.
|
<K,V> RedisAsyncConnection<K,V> |
connectAsync(RedisCodec<K,V> codec)
Open a new asynchronous connection to the redis server.
|
RedisPubSubConnection<java.lang.String,java.lang.String> |
connectPubSub()
Open a new pub/sub connection to the redis server that treats
keys and values as UTF-8 strings.
|
<K,V> RedisPubSubConnection<K,V> |
connectPubSub(RedisCodec<K,V> codec)
Open a new pub/sub connection to the redis server.
|
void |
setDefaultTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Set the default timeout for
connections created by
this client. |
void |
shutdown()
Shutdown this client and close all open connections.
|
private org.jboss.netty.bootstrap.ClientBootstrap bootstrap
private org.jboss.netty.util.Timer timer
private org.jboss.netty.channel.group.ChannelGroup channels
private long timeout
private java.util.concurrent.TimeUnit unit
public RedisClient(java.lang.String host)
host - Server hostname.public RedisClient(java.lang.String host,
int port)
timeout
after 60 seconds.host - Server hostname.port - Server port.public void setDefaultTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
connections created by
this client. The timeout applies to connection attempts and non-blocking
commands.timeout - Default connection timeout.unit - Unit of time for the timeout.public RedisConnection<java.lang.String,java.lang.String> connect()
public RedisAsyncConnection<java.lang.String,java.lang.String> connectAsync()
public RedisPubSubConnection<java.lang.String,java.lang.String> connectPubSub()
public <K,V> RedisConnection<K,V> connect(RedisCodec<K,V> codec)
codec to encode/decode keys and values.codec - Use this codec to encode/decode keys and values.public <K,V> RedisAsyncConnection<K,V> connectAsync(RedisCodec<K,V> codec)
codec to encode/decode keys and values.codec - Use this codec to encode/decode keys and values.public <K,V> RedisPubSubConnection<K,V> connectPubSub(RedisCodec<K,V> codec)
codec to encode/decode keys and values.codec - Use this codec to encode/decode keys and values.private <K,V,T extends RedisAsyncConnection<K,V>> T connect(CommandHandler<K,V> handler, T connection)
public void shutdown()