public class LettuceConnection extends AbstractRedisConnection
RedisConnection implementation on top of Lettuce Redis
client.RedisStringCommands.BitOperation, RedisStringCommands.SetOptionRedisListCommands.PositionRedisZSetCommands.Aggregate, RedisZSetCommands.Limit, RedisZSetCommands.Range, RedisZSetCommands.TupleRedisServerCommands.MigrateOption, RedisServerCommands.ShutdownOptionRedisGeoCommands.DistanceUnit, RedisGeoCommands.GeoLocation<T>, RedisGeoCommands.GeoRadiusCommandArgs| Constructor and Description |
|---|
LettuceConnection(long timeout,
io.lettuce.core.RedisClient client)
Instantiates a new lettuce connection.
|
LettuceConnection(long timeout,
io.lettuce.core.RedisClient client,
LettucePool pool)
Instantiates a new lettuce connection.
|
LettuceConnection(io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> sharedConnection,
long timeout,
io.lettuce.core.AbstractRedisClient client,
LettucePool pool,
int defaultDbIndex) |
LettuceConnection(io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> sharedConnection,
long timeout,
io.lettuce.core.RedisClient client)
Instantiates a new lettuce connection.
|
LettuceConnection(io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> sharedConnection,
long timeout,
io.lettuce.core.RedisClient client,
LettucePool pool)
Instantiates a new lettuce connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes (or quits) the connection.
|
List<Object> |
closePipeline()
Executes the commands in the pipeline and returns their result.
|
protected DataAccessException |
convertLettuceAccessException(Exception ex) |
void |
discard()
Discard all commands issued after
RedisTxCommands.multi(). |
protected io.lettuce.core.api.StatefulConnection<byte[],byte[]> |
doGetAsyncDedicatedConnection() |
byte[] |
echo(byte[] message)
Returns
message via server roundtrip. |
List<Object> |
exec()
Executes all queued commands in a transaction started with
RedisTxCommands.multi(). |
Object |
execute(String command,
byte[]... args)
'Native' or 'raw' execution of the given command along-side the given arguments.
|
Object |
execute(String command,
io.lettuce.core.output.CommandOutput commandOutputTypeHint,
byte[]... args)
'Native' or 'raw' execution of the given command along-side the given arguments.
|
RedisGeoCommands |
geoCommands()
Get
RedisGeoCommands. |
protected io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands<byte[],byte[]> |
getAsyncDedicatedConnection() |
protected io.lettuce.core.cluster.api.sync.RedisClusterCommands<byte[],byte[]> |
getConnection() |
io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands<byte[],byte[]> |
getNativeConnection()
Returns the native connection (the underlying library/driver object).
|
protected RedisSentinelConnection |
getSentinelConnection(RedisNode sentinel)
Get
RedisSentinelCommands connected to given node. |
Subscription |
getSubscription()
Returns the current subscription for this connection or null if the connection is not subscribed.
|
RedisHashCommands |
hashCommands()
Get
RedisHashCommands. |
RedisHyperLogLogCommands |
hyperLogLogCommands()
|
protected boolean |
isActive(RedisNode node)
Check if node is active by sending ping.
|
boolean |
isClosed()
Indicates whether the underlying connection is closed or not.
|
boolean |
isPipelined()
Indicates whether the connection is currently pipelined or not.
|
boolean |
isQueueing()
Indicates whether the connection is in "queue"(or "MULTI") mode or not.
|
boolean |
isSubscribed()
Indicates whether the current connection is subscribed (to at least one channel) or not.
|
RedisKeyCommands |
keyCommands()
Get
RedisKeyCommands. |
RedisListCommands |
listCommands()
Get
RedisListCommands. |
void |
multi()
Mark the start of a transaction block.
|
void |
openPipeline()
Activates the pipeline mode for this connection.
|
String |
ping()
Test connection.
|
void |
pSubscribe(MessageListener listener,
byte[]... patterns)
Subscribes the connection to all channels matching the given patterns.
|
Long |
publish(byte[] channel,
byte[] message)
Publishes the given message to the given channel.
|
RedisScriptingCommands |
scriptingCommands()
|
void |
select(int dbIndex)
Select the DB with given positive
dbIndex. |
RedisServerCommands |
serverCommands()
Get
RedisServerCommands. |
RedisSetCommands |
setCommands()
Get
RedisSetCommands. |
void |
setConvertPipelineAndTxResults(boolean convertPipelineAndTxResults)
Specifies if pipelined and transaction results should be converted to the expected data type.
|
RedisStringCommands |
stringCommands()
Get
RedisStringCommands. |
void |
subscribe(MessageListener listener,
byte[]... channels)
Subscribes the connection to the given channels.
|
void |
unwatch()
Flushes all the previously
#watch(byte[]...) keys. |
void |
watch(byte[]... keys)
Watch given
keys for modifications during transaction started with RedisTxCommands.multi(). |
RedisZSetCommands |
zSetCommands()
Get
RedisZSetCommands. |
getSentinelConnection, hasRedisSentinelConfigured, setSentinelConfigurationclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappend, bgReWriteAof, bgSave, bgWriteAof, bitCount, bitCount, bitOp, bLPop, bRPop, bRPopLPush, dbSize, decr, decrBy, del, dump, eval, evalSha, evalSha, exists, expire, expireAt, flushAll, flushDb, geoAdd, geoAdd, geoAdd, geoDist, geoDist, geoHash, geoPos, geoRadius, geoRadius, geoRadiusByMember, geoRadiusByMember, geoRemove, get, getBit, getClientList, getClientName, getConfig, getRange, getSet, hDel, hExists, hGet, hGetAll, hIncrBy, hIncrBy, hKeys, hLen, hMGet, hMSet, hScan, hSet, hSetNX, hVals, incr, incrBy, incrBy, info, info, keys, killClient, lastSave, lIndex, lInsert, lLen, lPop, lPush, lPushX, lRange, lRem, lSet, lTrim, mGet, migrate, migrate, move, mSet, mSetNX, persist, pExpire, pExpireAt, pfAdd, pfCount, pfMerge, pSetEx, pTtl, pTtl, randomKey, rename, renameNX, resetConfigStats, restore, rPop, rPopLPush, rPush, rPushX, sAdd, save, scan, sCard, scriptExists, scriptFlush, scriptKill, scriptLoad, sDiff, sDiffStore, set, set, setBit, setClientName, setConfig, setEx, setNX, setRange, shutdown, shutdown, sInter, sInterStore, sIsMember, slaveOf, slaveOfNoOne, sMembers, sMove, sort, sort, sPop, sRandMember, sRandMember, sRem, sScan, strLen, sUnion, sUnionStore, time, ttl, ttl, type, zAdd, zAdd, zCard, zCount, zCount, zIncrBy, zInterStore, zInterStore, zRange, zRangeByLex, zRangeByScore, zRangeByScore, zRangeByScore, zRangeByScoreWithScores, zRangeWithScores, zRank, zRem, zRemRange, zRemRangeByScore, zRemRangeByScore, zRevRange, zRevRangeByScore, zRevRangeByScoreWithScores, zRevRangeWithScores, zRevRank, zScan, zScore, zUnionStore, zUnionStorezRangeByLex, zRangeByLex, zRangeByScore, zRangeByScore, zRangeByScore, zRangeByScoreWithScores, zRangeByScoreWithScores, zRangeByScoreWithScores, zRevRangeByScore, zRevRangeByScore, zRevRangeByScore, zRevRangeByScoreWithScores, zRevRangeByScoreWithScores, zRevRangeByScoreWithScoresgeoAdd, geoRadiusByMemberpublic LettuceConnection(long timeout,
io.lettuce.core.RedisClient client)
timeout - The connection timeout (in milliseconds)client - The RedisClient to use when instantiating a native connectionpublic LettuceConnection(long timeout,
io.lettuce.core.RedisClient client,
LettucePool pool)
timeout - The connection timeout (in milliseconds) * @param client The RedisClient to use when
instantiating a pub/sub connectionpool - The connection pool to use for all other native connectionspublic LettuceConnection(io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> sharedConnection,
long timeout,
io.lettuce.core.RedisClient client)
sharedConnection - A native connection that is shared with other LettuceConnections. Will not be used
for transactions or blocking operationstimeout - The connection timeout (in milliseconds)client - The RedisClient to use when making pub/sub, blocking, and tx connectionspublic LettuceConnection(io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> sharedConnection,
long timeout,
io.lettuce.core.RedisClient client,
LettucePool pool)
sharedConnection - A native connection that is shared with other LettuceConnections. Should not be
used for transactions or blocking operationstimeout - The connection timeout (in milliseconds)client - The RedisClient to use when making pub/sub connectionspool - The connection pool to use for blocking and tx operationspublic LettuceConnection(io.lettuce.core.api.StatefulRedisConnection<byte[],byte[]> sharedConnection,
long timeout,
io.lettuce.core.AbstractRedisClient client,
LettucePool pool,
int defaultDbIndex)
sharedConnection - A native connection that is shared with other LettuceConnections. Should not be
used for transactions or blocking operationstimeout - The connection timeout (in milliseconds)client - The RedisClient to use when making pub/sub connections.pool - The connection pool to use for blocking and tx operations.defaultDbIndex - The db index to use along with RedisClient when establishing a dedicated connection.protected DataAccessException convertLettuceAccessException(Exception ex)
public RedisGeoCommands geoCommands()
RedisConnectionRedisGeoCommands.public RedisHashCommands hashCommands()
RedisConnectionRedisHashCommands.public RedisHyperLogLogCommands hyperLogLogCommands()
RedisConnectionpublic RedisKeyCommands keyCommands()
RedisConnectionRedisKeyCommands.public RedisListCommands listCommands()
RedisConnectionRedisListCommands.public RedisSetCommands setCommands()
RedisConnectionRedisSetCommands.public RedisScriptingCommands scriptingCommands()
RedisConnectionpublic RedisStringCommands stringCommands()
RedisConnectionRedisStringCommands.public RedisServerCommands serverCommands()
RedisConnectionRedisServerCommands.public RedisZSetCommands zSetCommands()
RedisConnectionRedisZSetCommands.public Object execute(String command, byte[]... args)
RedisCommandscommand - Command to executeargs - Possible command arguments (may be null)public Object execute(String command, io.lettuce.core.output.CommandOutput commandOutputTypeHint, byte[]... args)
command - Command to executecommandOutputTypeHint - Type of Output to use, may be (may be null).args - Possible command arguments (may be null)public void close()
throws DataAccessException
RedisConnectionclose in interface RedisConnectionclose in class AbstractRedisConnectionDataAccessExceptionpublic boolean isClosed()
RedisConnectionpublic io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands<byte[],byte[]> getNativeConnection()
RedisConnectionpublic boolean isQueueing()
RedisConnectionpublic boolean isPipelined()
RedisConnectionRedisConnection.openPipeline(),
RedisConnection.isQueueing()public void openPipeline()
RedisConnectionRedisConnection.closePipeline(). Calling this method when the connection is already pipelined has no effect.
Pipelining is used for issuing commands without requesting the response right away but rather at the end of the
batch. While somewhat similar to MULTI, pipelining does not guarantee atomicity - it only tries to improve
performance when issuing a lot of commands (such as in batching scenarios).
Note:
Consider doing some performance testing before using this feature since in many cases the performance benefits are minimal yet the impact on usage are not.RedisTxCommands.multi()public List<Object> closePipeline()
RedisConnectionpublic byte[] echo(byte[] message)
RedisConnectionCommandsmessage via server roundtrip.message - the message to echo.public String ping()
RedisConnectionCommandspublic void discard()
RedisTxCommandsRedisTxCommands.multi().public List<Object> exec()
RedisTxCommandsRedisTxCommands.multi(). #watch(byte[]...) the operation will fail if any of watched keys has been modified.public void multi()
RedisTxCommandsRedisTxCommands.exec() or rolled back using RedisTxCommands.discard()
public void select(int dbIndex)
RedisConnectionCommandsdbIndex.dbIndex - the database index.public void unwatch()
RedisTxCommands#watch(byte[]...) keys.public void watch(byte[]... keys)
RedisTxCommandskeys for modifications during transaction started with RedisTxCommands.multi().keys - must not be null.public Long publish(byte[] channel, byte[] message)
RedisPubSubCommandschannel - the channel to publish to, must not be null.message - message to publishpublic Subscription getSubscription()
RedisPubSubCommandspublic boolean isSubscribed()
RedisPubSubCommandspublic void pSubscribe(MessageListener listener, byte[]... patterns)
RedisPubSubCommandsNote that this operation is blocking and the current thread starts waiting for new messages immediately.
listener - message listener, must not be null.patterns - channel name patterns, must not be null.public void subscribe(MessageListener listener, byte[]... channels)
RedisPubSubCommandsNote that this operation is blocking and the current thread starts waiting for new messages immediately.
listener - message listener, must not be null.channels - channel names, must not be null.public void setConvertPipelineAndTxResults(boolean convertPipelineAndTxResults)
closePipeline() and exec() will be of the type returned by the Lettuce driverconvertPipelineAndTxResults - Whether or not to convert pipeline and tx resultsprotected io.lettuce.core.cluster.api.sync.RedisClusterCommands<byte[],byte[]> getConnection()
protected io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands<byte[],byte[]> getAsyncDedicatedConnection()
protected io.lettuce.core.api.StatefulConnection<byte[],byte[]> doGetAsyncDedicatedConnection()
protected boolean isActive(RedisNode node)
AbstractRedisConnectionisActive in class AbstractRedisConnectionprotected RedisSentinelConnection getSentinelConnection(RedisNode sentinel)
AbstractRedisConnectionRedisSentinelCommands connected to given node.getSentinelConnection in class AbstractRedisConnectionCopyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.