Spring Data Key-Value

org.springframework.data.keyvalue.redis.connection
Interface RedisConnection

All Superinterfaces:
RedisCommands, RedisHashCommands, RedisListCommands, RedisPubSubCommands, RedisServerCommands, RedisSetCommands, RedisStringCommands, RedisTxCommands, RedisZSetCommands
All Known Subinterfaces:
StringRedisConnection
All Known Implementing Classes:
DefaultStringRedisConnection, JedisConnection, JredisConnection

public interface RedisConnection
extends RedisCommands

A connection to a Redis server. Acts as an common abstraction across various Redis client libraries (or drivers). Additionally performs exception translation between the underlying Redis client library and Spring DAO exceptions. The methods follow as much as possible the Redis names and conventions.

Author:
Costin Leau

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.springframework.data.keyvalue.redis.connection.RedisListCommands
RedisListCommands.Position
 
Nested classes/interfaces inherited from interface org.springframework.data.keyvalue.redis.connection.RedisZSetCommands
RedisZSetCommands.Aggregate, RedisZSetCommands.Tuple
 
Method Summary
 void close()
          Closes (or quits) the connection.
 List<Object> closePipeline()
          Executes the commands in the pipeline and returns their result.
 Object getNativeConnection()
          Returns the native connection (the underlying library/driver object).
 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.
 void openPipeline()
          Activates the pipeline mode for this connection.
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisCommands
del, echo, exists, expire, expireAt, keys, persist, ping, randomKey, rename, renameNX, select, sort, sort, ttl, type
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisTxCommands
discard, exec, multi, unwatch, watch
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisStringCommands
append, decr, decrBy, get, getBit, getRange, getSet, incr, incrBy, mGet, mSet, mSetNX, set, setBit, setEx, setNX, setRange, strLen
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisListCommands
bLPop, bRPop, bRPopLPush, lIndex, lInsert, lLen, lPop, lPush, lPushX, lRange, lRem, lSet, lTrim, rPop, rPopLPush, rPush, rPushX
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisSetCommands
sAdd, sCard, sDiff, sDiffStore, sInter, sInterStore, sIsMember, sMembers, sMove, sPop, sRandMember, sRem, sUnion, sUnionStore
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisZSetCommands
zAdd, zCard, zCount, zIncrBy, zInterStore, zInterStore, zRange, zRangeByScore, zRangeByScore, zRangeByScoreWithScore, zRangeByScoreWithScore, zRangeWithScore, zRank, zRem, zRemRange, zRemRangeByScore, zRevRange, zRevRangeWithScore, zRevRank, zScore, zUnionStore, zUnionStore
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisHashCommands
hDel, hExists, hGet, hGetAll, hIncrBy, hKeys, hLen, hMGet, hMSet, hSet, hSetNX, hVals
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisServerCommands
bgSave, bgWriteAof, dbSize, flushAll, flushDb, getConfig, info, lastSave, resetConfigStats, save, setConfig, shutdown
 
Methods inherited from interface org.springframework.data.keyvalue.redis.connection.RedisPubSubCommands
getSubscription, isSubscribed, pSubscribe, publish, subscribe
 

Method Detail

close

void close()
           throws DataAccessException
Closes (or quits) the connection.

Throws:
DataAccessException

isClosed

boolean isClosed()
Indicates whether the underlying connection is closed or not.

Returns:
true if the connection is closed, false otherwise.

getNativeConnection

Object getNativeConnection()
Returns the native connection (the underlying library/driver object).

Returns:
underlying, native object

isQueueing

boolean isQueueing()
Indicates whether the connection is in "queue"(or "MULTI") mode or not. When queueing, all commands are postponed until EXEC or DISCARD commands are issued. Since in queueing no results are returned, the connection will return NULL on all operations that interact with the data.

Returns:
true if the connection is in queue/MULTI mode, false otherwise

isPipelined

boolean isPipelined()
Indicates whether the connection is currently pipelined or not.

Returns:
true if the connection is pipelined, false otherwise
See Also:
openPipeline(), isQueueing()

openPipeline

void openPipeline()
Activates the pipeline mode for this connection. When pipelined, all commands return null (the reply is read at the end through 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.

See Also:
RedisTxCommands.multi()

closePipeline

List<Object> closePipeline()
Executes the commands in the pipeline and returns their result. If the connection is not pipelined, an empty collection is returned.

Returns:
the result of the executed commands.

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.