public class JedisConnection extends AbstractRedisConnection
RedisConnection implementation on top of Jedis library.RedisStringCommands.BitOperation, RedisStringCommands.SetOptionRedisListCommands.Direction, RedisListCommands.PositionRedisZSetCommands.Aggregate, RedisZSetCommands.Limit, RedisZSetCommands.Range, RedisZSetCommands.Tuple, RedisZSetCommands.Weights, RedisZSetCommands.ZAddArgsRedisServerCommands.MigrateOption, RedisServerCommands.ShutdownOptionRedisStreamCommands.XAddOptions, RedisStreamCommands.XClaimOptions, RedisStreamCommands.XPendingOptionsRedisGeoCommands.DistanceUnit, RedisGeoCommands.GeoCommandArgs, RedisGeoCommands.GeoLocation<T>, RedisGeoCommands.GeoRadiusCommandArgs, RedisGeoCommands.GeoSearchCommandArgs, RedisGeoCommands.GeoSearchStoreCommandArgs| Modifier | Constructor and Description |
|---|---|
|
JedisConnection(redis.clients.jedis.Jedis jedis)
Constructs a new
JedisConnection instance. |
|
JedisConnection(redis.clients.jedis.Jedis jedis,
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool,
int dbIndex)
Constructs a new
JedisConnection instance backed by a jedis pool. |
protected |
JedisConnection(redis.clients.jedis.Jedis jedis,
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool,
int dbIndex,
String clientName)
Constructs a new
JedisConnection instance backed by a jedis pool. |
protected |
JedisConnection(redis.clients.jedis.Jedis jedis,
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool,
redis.clients.jedis.JedisClientConfig nodeConfig,
redis.clients.jedis.JedisClientConfig sentinelConfig)
Constructs a new
JedisConnection instance backed by a jedis pool. |
| 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 |
convertJedisAccessException(Exception ex) |
void |
discard()
Discard all commands issued after
RedisTxCommands.multi(). |
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.
|
RedisGeoCommands |
geoCommands()
Get
RedisGeoCommands. |
redis.clients.jedis.Jedis |
getJedis() |
protected redis.clients.jedis.Jedis |
getJedis(RedisNode node) |
redis.clients.jedis.Jedis |
getNativeConnection()
Returns the native connection (the underlying library/driver object).
|
redis.clients.jedis.Pipeline |
getPipeline() |
redis.clients.jedis.Pipeline |
getRequiredPipeline() |
redis.clients.jedis.Transaction |
getRequiredTransaction() |
protected JedisSentinelConnection |
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.
|
redis.clients.jedis.Transaction |
getTransaction() |
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 results should be converted to the expected data type.
|
RedisStreamCommands |
streamCommands()
Get
RedisStreamCommands. |
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, bitField, bitOp, bitPos, bLMove, bLPop, bRPop, bRPopLPush, bZPopMax, bZPopMin, copy, dbSize, decr, decrBy, del, dump, encodingOf, eval, evalSha, evalSha, exists, exists, expire, expireAt, flushAll, flushDb, geoAdd, geoAdd, geoAdd, geoDist, geoDist, geoHash, geoPos, geoRadius, geoRadius, geoRadiusByMember, geoRadiusByMember, geoRemove, geoSearch, geoSearchStore, get, getBit, getClientList, getClientName, getConfig, getDel, getEx, getRange, getSet, hDel, hExists, hGet, hGetAll, hIncrBy, hIncrBy, hKeys, hLen, hMGet, hMSet, hRandField, hRandField, hRandFieldWithValues, hRandFieldWithValues, hScan, hSet, hSetNX, hStrLen, hVals, idletime, incr, incrBy, incrBy, info, info, keys, killClient, lastSave, lIndex, lInsert, lLen, lMove, lPop, lPop, lPos, lPush, lPushX, lRange, lRem, lSet, lTrim, mGet, migrate, migrate, move, mSet, mSetNX, persist, pExpire, pExpireAt, pfAdd, pfCount, pfMerge, pSetEx, pTtl, pTtl, randomKey, refcount, rename, renameNX, resetConfigStats, restore, rewriteConfig, rPop, 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, sMIsMember, sMove, sort, sort, sPop, sPop, sRandMember, sRandMember, sRem, sScan, strLen, sUnion, sUnionStore, time, time, touch, ttl, ttl, type, unlink, xAck, xAdd, xClaim, xClaimJustId, xDel, xGroupCreate, xGroupCreate, xGroupDelConsumer, xGroupDestroy, xInfo, xInfoConsumers, xInfoGroups, xLen, xPending, xPending, xRange, xRange, xRead, xRead, xReadGroup, xReadGroup, xRevRange, xRevRange, xTrim, xTrim, zAdd, zAdd, zCard, zCount, zCount, zDiff, zDiffStore, zDiffWithScores, zIncrBy, zInter, zInterStore, zInterStore, zInterStore, zInterWithScores, zInterWithScores, zInterWithScores, zLexCount, zMScore, zPopMax, zPopMax, zPopMin, zPopMin, zRandMember, zRandMember, zRandMemberWithScore, zRandMemberWithScore, zRange, zRangeByLex, zRangeByScore, zRangeByScore, zRangeByScore, zRangeByScoreWithScores, zRangeWithScores, zRank, zRem, zRemRange, zRemRangeByLex, zRemRangeByScore, zRemRangeByScore, zRevRange, zRevRangeByLex, zRevRangeByScore, zRevRangeByScoreWithScores, zRevRangeWithScores, zRevRank, zScan, zScore, zUnion, zUnionStore, zUnionStore, zUnionStore, zUnionWithScores, zUnionWithScores, zUnionWithScoresrestore, scanbitPoslPoszAdd, zAdd, zRangeByLex, zRangeByLex, zRangeByScore, zRangeByScore, zRangeByScore, zRangeByScoreWithScores, zRangeByScoreWithScores, zRangeByScoreWithScores, zRevRangeByLex, zRevRangeByLex, zRevRangeByScore, zRevRangeByScore, zRevRangeByScore, zRevRangeByScoreWithScores, zRevRangeByScoreWithScores, zRevRangeByScoreWithScoresxAck, xAdd, xAdd, xClaim, xDel, xGroupDelConsumer, xPending, xPending, xPending, xPending, xPendinggeoAdd, geoRadiusByMemberpublic JedisConnection(redis.clients.jedis.Jedis jedis)
JedisConnection instance.jedis - Jedis entitypublic JedisConnection(redis.clients.jedis.Jedis jedis,
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool,
int dbIndex)
JedisConnection instance backed by a jedis pool.jedis - pool - can be null, if no pool is useddbIndex - protected JedisConnection(redis.clients.jedis.Jedis jedis,
@Nullable
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool,
int dbIndex,
@Nullable
String clientName)
JedisConnection instance backed by a jedis pool.jedis - pool - can be null, if no pool is useddbIndex - clientName - the client name, can be null.protected JedisConnection(redis.clients.jedis.Jedis jedis,
@Nullable
redis.clients.jedis.util.Pool<redis.clients.jedis.Jedis> pool,
redis.clients.jedis.JedisClientConfig nodeConfig,
redis.clients.jedis.JedisClientConfig sentinelConfig)
JedisConnection instance backed by a jedis pool.jedis - pool - can be null, if no pool is usednodeConfig - node configurationsentinelConfig - sentinel configurationprotected DataAccessException convertJedisAccessException(Exception ex)
public RedisKeyCommands keyCommands()
RedisConnectionRedisKeyCommands.public RedisStreamCommands streamCommands()
RedisConnectionRedisStreamCommands.public RedisStringCommands stringCommands()
RedisConnectionRedisStringCommands.public RedisListCommands listCommands()
RedisConnectionRedisListCommands.public RedisSetCommands setCommands()
RedisConnectionRedisSetCommands.public RedisZSetCommands zSetCommands()
RedisConnectionRedisZSetCommands.public RedisHashCommands hashCommands()
RedisConnectionRedisHashCommands.public RedisGeoCommands geoCommands()
RedisConnectionRedisGeoCommands.public RedisScriptingCommands scriptingCommands()
RedisConnectionpublic RedisServerCommands serverCommands()
RedisConnectionRedisServerCommands.public RedisHyperLogLogCommands hyperLogLogCommands()
RedisConnectionpublic Object execute(String command, byte[]... args)
RedisCommandscommand - Command to execute. must not be null.args - Possible command arguments (may be empty).public void close()
throws DataAccessException
RedisConnectionclose in interface AutoCloseableclose in interface RedisConnectionclose in class AbstractRedisConnectionDataAccessExceptionpublic redis.clients.jedis.Jedis getNativeConnection()
RedisConnectionpublic boolean isClosed()
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.@Nullable public redis.clients.jedis.Pipeline getPipeline()
public redis.clients.jedis.Pipeline getRequiredPipeline()
@Nullable public redis.clients.jedis.Transaction getTransaction()
public redis.clients.jedis.Transaction getRequiredTransaction()
public redis.clients.jedis.Jedis getJedis()
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 publish. Must not be null.public 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 Jedis driverconvertPipelineAndTxResults - Whether or not to convert pipeline and tx resultsprotected boolean isActive(RedisNode node)
AbstractRedisConnectionisActive in class AbstractRedisConnectionprotected JedisSentinelConnection getSentinelConnection(RedisNode sentinel)
AbstractRedisConnectionRedisSentinelCommands connected to given node.getSentinelConnection in class AbstractRedisConnectionprotected redis.clients.jedis.Jedis getJedis(RedisNode node)
Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.