Class RedisClientProtocolHandler
- All Implemented Interfaces:
ProtocolHandler,RedisSession
Implements ProtocolHandler and RedisSession, storing an
Endpoint field set in connected(Endpoint) and delegating
all I/O to the endpoint.
Commands are encoded as RESP arrays of bulk strings
(RESP spec — "Sending commands to a Redis server") and sent via the
endpoint. Responses are decoded by RESPDecoder and dispatched
to the appropriate callback in FIFO order (RESP spec — "Pipelining").
Supported RESP2 response types:
- Simple String (
+) — dispatched toStringResultHandler - Error (
-) — dispatched to handler'shandleError() - Integer (
:) — dispatched toIntegerResultHandler/BooleanResultHandler - Bulk String (
$) — dispatched toBulkResultHandler - Array (
*) — dispatched toArrayResultHandler
RESP3 types (Map, Set, Double, Boolean, Null, Push, Verbatim String,
Big Number, Blob Error) are decoded and dispatched. RESP3 Maps received
by ArrayResultHandler are flattened to alternating key/value lists.
The HELLO command negotiates the RESP protocol version (RESP3).
Pub/Sub push messages are handled out-of-band when in Pub/Sub mode (RESP spec — "Pub/Sub" / "Push type"). In RESP3, Push (>) replaces the array-based Pub/Sub detection with a dedicated type.
- Author:
- Chris Burdess
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a Redis client endpoint handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(String key, String value, IntegerResultHandler h) Appends a value to a string.voidauth(String username, String password, StringResultHandler h) Authenticates with username and password (Redis 6+ ACL).voidauth(String password, StringResultHandler h) Authenticates with a password (Redis 5 and earlier).voidblmove(String source, String destination, String whereFrom, String whereTo, double timeout, BulkResultHandler h) Blocking move of an element from one list to another (Redis 6.2+).voidblpop(double timeout, ArrayResultHandler h, String... keys) Blocking pop from the left (head) of one or more lists.voidbrpop(double timeout, ArrayResultHandler h, String... keys) Blocking pop from the right (tail) of one or more lists.voidGets the connection name.voidReturns the unique client ID of the current connection.voidclientSetName(String name, StringResultHandler h) Sets the connection name (visible in CLIENT LIST).voidclose()Closes the connection immediately.voidcommand(ArrayResultHandler h, String command, byte[]... args) Sends a raw command with byte array arguments.voidcommand(ArrayResultHandler h, String command, String... args) Sends a raw command with string arguments.voidCalled when the endpoint is established and ready for protocol traffic.voidGets the number of keys in the current database.voiddecr(String key, IntegerResultHandler h) Decrements an integer value.voiddecrby(String key, long decrement, IntegerResultHandler h) Decrements by a specific amount.voiddel(IntegerResultHandler h, String... keys) Deletes one or more keys.voidDiscards all queued commands.voidCalled when the peer has closed the connection or stream.voidecho(String message, BulkResultHandler h) Echoes a message.voidCalled when an unrecoverable error occurs on the endpoint.voideval(String script, int numKeys, String[] keys, String[] args, ArrayResultHandler h) Executes a Lua script.voidevalsha(String sha1, int numKeys, String[] keys, String[] args, ArrayResultHandler h) Executes a cached script by SHA1 hash.voidExecutes all queued commands in a transaction.voidexists(String key, BooleanResultHandler h) Checks if a key exists.voidexists(IntegerResultHandler h, String... keys) Checks how many of the specified keys exist.voidexpire(String key, int seconds, BooleanResultHandler h) Sets an expiration time in seconds.voidexpireat(String key, long timestamp, BooleanResultHandler h) Sets an expiration time as a Unix timestamp (seconds).voidFlushes all databases.voidFlushes the current database.voidget(String key, BulkResultHandler h) Gets the value of a key.voidgetset(String key, String value, BulkResultHandler h) Gets the old value and sets a new value.voidhdel(String key, IntegerResultHandler h, String... fields) Deletes hash fields.voidhello(int protover, String username, String password, ArrayResultHandler h) Sends a HELLO command with authentication.voidhello(int protover, ArrayResultHandler h) Sends a HELLO command to negotiate the RESP protocol version and optionally authenticate in a single round-trip (Redis 6+).voidhexists(String key, String field, BooleanResultHandler h) Checks if a hash field exists.voidhget(String key, String field, BulkResultHandler h) Gets a hash field value.voidhgetall(String key, ArrayResultHandler h) Gets all fields and values in a hash.voidhincrby(String key, String field, long increment, IntegerResultHandler h) Increments a hash field by an integer.voidhincrbyfloat(String key, String field, double increment, BulkResultHandler h) Increments a hash field by a float.voidhkeys(String key, ArrayResultHandler h) Gets all field names in a hash.voidhlen(String key, IntegerResultHandler h) Gets the number of fields in a hash.voidhmget(String key, ArrayResultHandler h, String... fields) Gets multiple hash fields.voidhmset(String key, StringResultHandler h, String... fieldsAndValues) Sets multiple hash fields.voidhscan(String key, String cursor, String match, int count, ScanResultHandler h) Incrementally iterates over fields in a hash with MATCH and COUNT.voidhscan(String key, String cursor, ScanResultHandler h) Incrementally iterates over fields in a hash.voidhset(String key, String field, byte[] value, IntegerResultHandler h) Sets a hash field with binary value.voidhset(String key, String field, String value, IntegerResultHandler h) Sets a hash field.voidhsetnx(String key, String field, String value, BooleanResultHandler h) Sets a hash field only if it doesn't exist.voidhvals(String key, ArrayResultHandler h) Gets all values in a hash.voidincr(String key, IntegerResultHandler h) Increments an integer value.voidincrby(String key, long increment, IntegerResultHandler h) Increments by a specific amount.voidincrbyfloat(String key, double increment, BulkResultHandler h) Increments a float value.voidinfo(String section, BulkResultHandler h) Gets server information for a specific section.voidGets server information.voidkeys(String pattern, ArrayResultHandler h) Finds all keys matching a pattern.voidlindex(String key, int index, BulkResultHandler h) Gets an element by index.voidllen(String key, IntegerResultHandler h) Gets the length of a list.voidlpop(String key, BulkResultHandler h) Pops a value from the left (head) of a list.voidlpush(String key, IntegerResultHandler h, String... values) Pushes values to the left (head) of a list.voidlrange(String key, int start, int stop, ArrayResultHandler h) Gets a range of elements from a list.voidlrem(String key, int count, String value, IntegerResultHandler h) Removes elements from a list.voidlset(String key, int index, String value, StringResultHandler h) Sets an element by index.voidltrim(String key, int start, int stop, StringResultHandler h) Trims a list to the specified range.voidmget(ArrayResultHandler h, String... keys) Gets multiple keys.voidmset(StringResultHandler h, String... keysAndValues) Sets multiple keys.voidMarks the start of a transaction.voidpersist(String key, BooleanResultHandler h) Removes the expiration from a key.voidpexpire(String key, long milliseconds, BooleanResultHandler h) Sets an expiration time in milliseconds.voidping(String message, BulkResultHandler h) Sends a PING command with a message.voidSends a PING command.voidpsetex(String key, long milliseconds, String value, StringResultHandler h) Sets a key with expiration in milliseconds.voidpsubscribe(MessageHandler h, String... patterns) Subscribes to channel patterns.voidpttl(String key, IntegerResultHandler h) Gets the remaining time to live in milliseconds.voidpublish(String channel, byte[] message, IntegerResultHandler h) Publishes a binary message to a channel.voidpublish(String channel, String message, IntegerResultHandler h) Publishes a message to a channel.voidpunsubscribe(String... patterns) Unsubscribes from patterns.voidquit()Closes the connection gracefully.voidreceive(ByteBuffer buf) Called when plaintext application data is received from the peer.voidrename(String oldKey, String newKey, StringResultHandler h) Renames a key.voidrenamenx(String oldKey, String newKey, BooleanResultHandler h) Renames a key only if the new key doesn't exist.voidResets the connection state, clearing Pub/Sub subscriptions, MULTI transaction, WATCH keys, and authenticated user (Redis command reference — RESET).voidrpop(String key, BulkResultHandler h) Pops a value from the right (tail) of a list.voidrpush(String key, IntegerResultHandler h, String... values) Pushes values to the right (tail) of a list.voidsadd(String key, IntegerResultHandler h, String... members) Adds members to a set.voidscan(String cursor, String match, int count, ScanResultHandler h) Incrementally iterates over the key space with MATCH and COUNT options.voidscan(String cursor, ScanResultHandler h) Incrementally iterates over the key space.voidscard(String key, IntegerResultHandler h) Gets the number of members in a set.voidCalled when the security layer becomes active.voidselect(int index, StringResultHandler h) Selects a database by index.voidset(String key, byte[] value, StringResultHandler h) Sets a key to a binary value.voidset(String key, String value, StringResultHandler h) Sets a key to a string value.voidsetex(String key, int seconds, String value, StringResultHandler h) Sets a key with expiration in seconds.voidsetnx(String key, String value, BooleanResultHandler h) Sets a key only if it doesn't exist.voidsismember(String key, String member, BooleanResultHandler h) Checks if a value is a member of a set.voidsmembers(String key, ArrayResultHandler h) Gets all members of a set.voidspop(String key, BulkResultHandler h) Pops a random member from a set.voidsrandmember(String key, BulkResultHandler h) Gets a random member without removing it.voidsrem(String key, IntegerResultHandler h, String... members) Removes members from a set.voidsscan(String key, String cursor, String match, int count, ScanResultHandler h) Incrementally iterates over members of a set with MATCH and COUNT.voidsscan(String key, String cursor, ScanResultHandler h) Incrementally iterates over members of a set.voidstrlen(String key, IntegerResultHandler h) Gets the length of a string value.voidsubscribe(MessageHandler h, String... channels) Subscribes to channels.voidReturns the server time.voidttl(String key, IntegerResultHandler h) Gets the remaining time to live in seconds.voidtype(String key, StringResultHandler h) Returns the type of a key.voidunsubscribe(String... channels) Unsubscribes from channels.voidUnwatches all keys.voidwatch(StringResultHandler h, String... keys) Watches keys for changes (optimistic locking).voidxack(String key, String group, IntegerResultHandler h, String... ids) Acknowledges one or more stream entries for a consumer group.voidxadd(String key, String id, BulkResultHandler h, String... fieldsAndValues) Appends an entry to a stream.voidxgroupCreate(String key, String group, String id, StringResultHandler h) Creates a consumer group for a stream.voidxgroupDestroy(String key, String group, IntegerResultHandler h) Deletes a consumer group.voidxlen(String key, IntegerResultHandler h) Returns the number of entries in a stream.voidxpending(String key, String group, ArrayResultHandler h) Returns the number of pending entries for a consumer group.voidxrange(String key, String start, String end, int count, ArrayResultHandler h) Returns a range of entries with a count limit.voidxrange(String key, String start, String end, ArrayResultHandler h) Returns a range of entries from a stream.voidxread(int count, long blockMillis, ArrayResultHandler h, String... keysAndIds) Reads entries from one or more streams, optionally blocking.voidxrevrange(String key, String end, String start, int count, ArrayResultHandler h) Returns a range of entries in reverse order with a count limit.voidxrevrange(String key, String end, String start, ArrayResultHandler h) Returns a range of entries in reverse order.voidxtrim(String key, long maxLen, IntegerResultHandler h) Trims a stream to approximately the specified length.voidzadd(String key, double score, String member, IntegerResultHandler h) Adds a member with a score to a sorted set.voidzcard(String key, IntegerResultHandler h) Gets the number of members in a sorted set.voidzincrby(String key, double increment, String member, BulkResultHandler h) Increments a member's score.voidzrange(String key, int start, int stop, ArrayResultHandler h) Gets members in a range by index.voidzrangeWithScores(String key, int start, int stop, ArrayResultHandler h) Gets members in a range by index with scores.voidzrank(String key, String member, IntegerResultHandler h) Gets the rank of a member (0-based, lowest score first).voidzrem(String key, IntegerResultHandler h, String... members) Removes members from a sorted set.voidzrevrange(String key, int start, int stop, ArrayResultHandler h) Gets members in reverse order by index.voidzscan(String key, String cursor, String match, int count, ScanResultHandler h) Incrementally iterates over members of a sorted set with MATCH and COUNT.voidzscan(String key, String cursor, ScanResultHandler h) Incrementally iterates over members of a sorted set.voidzscore(String key, String member, BulkResultHandler h) Gets the score of a member.
-
Constructor Details
-
RedisClientProtocolHandler
Creates a Redis client endpoint handler.- Parameters:
handler- the client handler for callbacks
-
-
Method Details
-
connected
Description copied from interface:ProtocolHandlerCalled when the endpoint is established and ready for protocol traffic.The endpoint reference passed here should be stored by the handler for sending data and querying connection state.
- Specified by:
connectedin interfaceProtocolHandler- Parameters:
ep- the endpoint that is now connected
-
receive
Description copied from interface:ProtocolHandlerCalled when plaintext application data is received from the peer.The buffer is in read mode (position at data start, limit at data end). The handler should consume as much data as it can. After this method returns, any unconsumed data (between the buffer's position and limit) will be preserved for the next call.
- Specified by:
receivein interfaceProtocolHandler- Parameters:
buf- the application data received
-
disconnected
public void disconnected()Description copied from interface:ProtocolHandlerCalled when the peer has closed the connection or stream.After this method returns, the endpoint is no longer usable. Protocol handlers should perform any cleanup here.
- Specified by:
disconnectedin interfaceProtocolHandler
-
securityEstablished
Description copied from interface:ProtocolHandlerCalled when the security layer becomes active.For TCP with STARTTLS, this is called after the TLS handshake completes. For QUIC (always secure), this is called before
ProtocolHandler.connected(Endpoint). For initially-secure TCP, this is also called beforeProtocolHandler.connected(Endpoint).Protocol handlers that need to reset state after STARTTLS (e.g., SMTP EHLO re-issue) should do so here.
- Specified by:
securityEstablishedin interfaceProtocolHandler- Parameters:
info- details about the negotiated security parameters
-
error
Description copied from interface:ProtocolHandlerCalled when an unrecoverable error occurs on the endpoint.This covers I/O errors, TLS handshake failures, and connection failures for client-initiated endpoints. The endpoint may or may not be usable after this call.
- Specified by:
errorin interfaceProtocolHandler- Parameters:
cause- the exception that caused the error
-
close
public void close()Description copied from interface:RedisSessionCloses the connection immediately.- Specified by:
closein interfaceRedisSession
-
auth
Description copied from interface:RedisSessionAuthenticates with a password (Redis 5 and earlier).- Specified by:
authin interfaceRedisSession- Parameters:
password- the passwordh- the result handler
-
auth
Description copied from interface:RedisSessionAuthenticates with username and password (Redis 6+ ACL).- Specified by:
authin interfaceRedisSession- Parameters:
username- the usernamepassword- the passwordh- the result handler
-
hello
Description copied from interface:RedisSessionSends a HELLO command to negotiate the RESP protocol version and optionally authenticate in a single round-trip (Redis 6+).HELLO returns a map of server properties including: server, version, proto, id, mode, role, modules.
- Specified by:
helloin interfaceRedisSession- Parameters:
protover- the RESP protocol version (2 or 3)h- receives the server properties as an array
-
hello
Description copied from interface:RedisSessionSends a HELLO command with authentication.- Specified by:
helloin interfaceRedisSession- Parameters:
protover- the RESP protocol version (2 or 3)username- the username (or "default")password- the passwordh- receives the server properties as an array
-
clientSetName
Description copied from interface:RedisSessionSets the connection name (visible in CLIENT LIST).- Specified by:
clientSetNamein interfaceRedisSession- Parameters:
name- the connection nameh- receives "OK"
-
clientGetName
Description copied from interface:RedisSessionGets the connection name.- Specified by:
clientGetNamein interfaceRedisSession- Parameters:
h- receives the connection name or null
-
clientId
Description copied from interface:RedisSessionReturns the unique client ID of the current connection.- Specified by:
clientIdin interfaceRedisSession- Parameters:
h- receives the client ID
-
ping
Description copied from interface:RedisSessionSends a PING command.- Specified by:
pingin interfaceRedisSession- Parameters:
h- receives "PONG"
-
ping
Description copied from interface:RedisSessionSends a PING command with a message.- Specified by:
pingin interfaceRedisSession- Parameters:
message- the message to echoh- receives the message back
-
select
Description copied from interface:RedisSessionSelects a database by index.- Specified by:
selectin interfaceRedisSession- Parameters:
index- the database index (0-15 typically)h- the result handler
-
echo
Description copied from interface:RedisSessionEchoes a message.- Specified by:
echoin interfaceRedisSession- Parameters:
message- the message to echoh- receives the message back
-
quit
public void quit()Description copied from interface:RedisSessionCloses the connection gracefully.- Specified by:
quitin interfaceRedisSession
-
reset
Description copied from interface:RedisSessionResets the connection state, clearing Pub/Sub subscriptions, MULTI transaction, WATCH keys, and authenticated user (Redis command reference — RESET).- Specified by:
resetin interfaceRedisSession- Parameters:
h- receives "RESET"
-
get
Description copied from interface:RedisSessionGets the value of a key.- Specified by:
getin interfaceRedisSession- Parameters:
key- the keyh- receives the value or null
-
set
Description copied from interface:RedisSessionSets a key to a string value.- Specified by:
setin interfaceRedisSession- Parameters:
key- the keyvalue- the valueh- receives "OK"
-
set
Description copied from interface:RedisSessionSets a key to a binary value.- Specified by:
setin interfaceRedisSession- Parameters:
key- the keyvalue- the value bytesh- receives "OK"
-
setex
Description copied from interface:RedisSessionSets a key with expiration in seconds.- Specified by:
setexin interfaceRedisSession- Parameters:
key- the keyseconds- the expiration time in secondsvalue- the valueh- receives "OK"
-
psetex
Description copied from interface:RedisSessionSets a key with expiration in milliseconds.- Specified by:
psetexin interfaceRedisSession- Parameters:
key- the keymilliseconds- the expiration time in millisecondsvalue- the valueh- receives "OK"
-
setnx
Description copied from interface:RedisSessionSets a key only if it doesn't exist.- Specified by:
setnxin interfaceRedisSession- Parameters:
key- the keyvalue- the valueh- receives true if set, false if key existed
-
getset
Description copied from interface:RedisSessionGets the old value and sets a new value.- Specified by:
getsetin interfaceRedisSession- Parameters:
key- the keyvalue- the new valueh- receives the old value or null
-
mget
Description copied from interface:RedisSessionGets multiple keys.- Specified by:
mgetin interfaceRedisSession- Parameters:
h- receives array of values (nulls for missing keys)keys- the keys
-
mset
Description copied from interface:RedisSessionSets multiple keys.- Specified by:
msetin interfaceRedisSession- Parameters:
h- receives "OK"keysAndValues- alternating keys and values
-
incr
Description copied from interface:RedisSessionIncrements an integer value.- Specified by:
incrin interfaceRedisSession- Parameters:
key- the keyh- receives the new value
-
incrby
Description copied from interface:RedisSessionIncrements by a specific amount.- Specified by:
incrbyin interfaceRedisSession- Parameters:
key- the keyincrement- the amount to addh- receives the new value
-
incrbyfloat
Description copied from interface:RedisSessionIncrements a float value.- Specified by:
incrbyfloatin interfaceRedisSession- Parameters:
key- the keyincrement- the amount to addh- receives the new value as a string
-
decr
Description copied from interface:RedisSessionDecrements an integer value.- Specified by:
decrin interfaceRedisSession- Parameters:
key- the keyh- receives the new value
-
decrby
Description copied from interface:RedisSessionDecrements by a specific amount.- Specified by:
decrbyin interfaceRedisSession- Parameters:
key- the keydecrement- the amount to subtracth- receives the new value
-
append
Description copied from interface:RedisSessionAppends a value to a string.- Specified by:
appendin interfaceRedisSession- Parameters:
key- the keyvalue- the value to appendh- receives the new string length
-
strlen
Description copied from interface:RedisSessionGets the length of a string value.- Specified by:
strlenin interfaceRedisSession- Parameters:
key- the keyh- receives the length
-
del
Description copied from interface:RedisSessionDeletes one or more keys.- Specified by:
delin interfaceRedisSession- Parameters:
h- receives the count of keys deletedkeys- the keys to delete
-
exists
Description copied from interface:RedisSessionChecks if a key exists.- Specified by:
existsin interfaceRedisSession- Parameters:
key- the keyh- receives true if exists
-
exists
Description copied from interface:RedisSessionChecks how many of the specified keys exist.- Specified by:
existsin interfaceRedisSession- Parameters:
h- receives the count of existing keyskeys- the keys to check
-
expire
Description copied from interface:RedisSessionSets an expiration time in seconds.- Specified by:
expirein interfaceRedisSession- Parameters:
key- the keyseconds- the expiration timeh- receives true if set, false if key doesn't exist
-
pexpire
Description copied from interface:RedisSessionSets an expiration time in milliseconds.- Specified by:
pexpirein interfaceRedisSession- Parameters:
key- the keymilliseconds- the expiration timeh- receives true if set, false if key doesn't exist
-
expireat
Description copied from interface:RedisSessionSets an expiration time as a Unix timestamp (seconds).- Specified by:
expireatin interfaceRedisSession- Parameters:
key- the keytimestamp- the Unix timestamph- receives true if set, false if key doesn't exist
-
ttl
Description copied from interface:RedisSessionGets the remaining time to live in seconds.- Specified by:
ttlin interfaceRedisSession- Parameters:
key- the keyh- receives TTL, -1 if no expiry, -2 if key doesn't exist
-
pttl
Description copied from interface:RedisSessionGets the remaining time to live in milliseconds.- Specified by:
pttlin interfaceRedisSession- Parameters:
key- the keyh- receives TTL, -1 if no expiry, -2 if key doesn't exist
-
persist
Description copied from interface:RedisSessionRemoves the expiration from a key.- Specified by:
persistin interfaceRedisSession- Parameters:
key- the keyh- receives true if removed, false if no expiry or key doesn't exist
-
keys
Description copied from interface:RedisSessionFinds all keys matching a pattern.- Specified by:
keysin interfaceRedisSession- Parameters:
pattern- the glob-style patternh- receives the matching keys
-
rename
Description copied from interface:RedisSessionRenames a key.- Specified by:
renamein interfaceRedisSession- Parameters:
oldKey- the current key namenewKey- the new key nameh- receives "OK"
-
renamenx
Description copied from interface:RedisSessionRenames a key only if the new key doesn't exist.- Specified by:
renamenxin interfaceRedisSession- Parameters:
oldKey- the current key namenewKey- the new key nameh- receives true if renamed, false if new key existed
-
type
Description copied from interface:RedisSessionReturns the type of a key.- Specified by:
typein interfaceRedisSession- Parameters:
key- the keyh- receives the type (string, list, set, zset, hash, stream)
-
scan
Description copied from interface:RedisSessionIncrementally iterates over the key space.- Specified by:
scanin interfaceRedisSession- Parameters:
cursor- the cursor ("0" to start)h- receives the cursor and elements
-
scan
Description copied from interface:RedisSessionIncrementally iterates over the key space with MATCH and COUNT options.- Specified by:
scanin interfaceRedisSession- Parameters:
cursor- the cursor ("0" to start)match- the glob-style pattern (null to skip)count- the hint for number of elements (0 to skip)h- receives the cursor and elements
-
hscan
Description copied from interface:RedisSessionIncrementally iterates over fields in a hash.- Specified by:
hscanin interfaceRedisSession- Parameters:
key- the hash keycursor- the cursor ("0" to start)h- receives the cursor and field-value pairs
-
hscan
Description copied from interface:RedisSessionIncrementally iterates over fields in a hash with MATCH and COUNT.- Specified by:
hscanin interfaceRedisSession- Parameters:
key- the hash keycursor- the cursor ("0" to start)match- the glob-style pattern (null to skip)count- the hint for number of elements (0 to skip)h- receives the cursor and field-value pairs
-
sscan
Description copied from interface:RedisSessionIncrementally iterates over members of a set.- Specified by:
sscanin interfaceRedisSession- Parameters:
key- the set keycursor- the cursor ("0" to start)h- receives the cursor and members
-
sscan
Description copied from interface:RedisSessionIncrementally iterates over members of a set with MATCH and COUNT.- Specified by:
sscanin interfaceRedisSession- Parameters:
key- the set keycursor- the cursor ("0" to start)match- the glob-style pattern (null to skip)count- the hint for number of elements (0 to skip)h- receives the cursor and members
-
zscan
Description copied from interface:RedisSessionIncrementally iterates over members of a sorted set.- Specified by:
zscanin interfaceRedisSession- Parameters:
key- the sorted set keycursor- the cursor ("0" to start)h- receives the cursor and member-score pairs
-
zscan
Description copied from interface:RedisSessionIncrementally iterates over members of a sorted set with MATCH and COUNT.- Specified by:
zscanin interfaceRedisSession- Parameters:
key- the sorted set keycursor- the cursor ("0" to start)match- the glob-style pattern (null to skip)count- the hint for number of elements (0 to skip)h- receives the cursor and member-score pairs
-
hget
Description copied from interface:RedisSessionGets a hash field value.- Specified by:
hgetin interfaceRedisSession- Parameters:
key- the keyfield- the field nameh- receives the value or null
-
hset
Description copied from interface:RedisSessionSets a hash field.- Specified by:
hsetin interfaceRedisSession- Parameters:
key- the keyfield- the field namevalue- the valueh- receives count of fields added (0 if updated, 1 if new)
-
hset
Description copied from interface:RedisSessionSets a hash field with binary value.- Specified by:
hsetin interfaceRedisSession- Parameters:
key- the keyfield- the field namevalue- the value bytesh- receives count of fields added
-
hsetnx
Description copied from interface:RedisSessionSets a hash field only if it doesn't exist.- Specified by:
hsetnxin interfaceRedisSession- Parameters:
key- the keyfield- the field namevalue- the valueh- receives true if set, false if field existed
-
hmget
Description copied from interface:RedisSessionGets multiple hash fields.- Specified by:
hmgetin interfaceRedisSession- Parameters:
key- the keyh- receives array of valuesfields- the field names
-
hmset
Description copied from interface:RedisSessionSets multiple hash fields.- Specified by:
hmsetin interfaceRedisSession- Parameters:
key- the keyh- receives "OK"fieldsAndValues- alternating field names and values
-
hgetall
Description copied from interface:RedisSessionGets all fields and values in a hash.- Specified by:
hgetallin interfaceRedisSession- Parameters:
key- the keyh- receives alternating field/value array
-
hkeys
Description copied from interface:RedisSessionGets all field names in a hash.- Specified by:
hkeysin interfaceRedisSession- Parameters:
key- the keyh- receives array of field names
-
hvals
Description copied from interface:RedisSessionGets all values in a hash.- Specified by:
hvalsin interfaceRedisSession- Parameters:
key- the keyh- receives array of values
-
hdel
Description copied from interface:RedisSessionDeletes hash fields.- Specified by:
hdelin interfaceRedisSession- Parameters:
key- the keyh- receives count of fields deletedfields- the field names
-
hexists
Description copied from interface:RedisSessionChecks if a hash field exists.- Specified by:
hexistsin interfaceRedisSession- Parameters:
key- the keyfield- the field nameh- receives true if exists
-
hlen
Description copied from interface:RedisSessionGets the number of fields in a hash.- Specified by:
hlenin interfaceRedisSession- Parameters:
key- the keyh- receives the count
-
hincrby
Description copied from interface:RedisSessionIncrements a hash field by an integer.- Specified by:
hincrbyin interfaceRedisSession- Parameters:
key- the keyfield- the field nameincrement- the amounth- receives the new value
-
hincrbyfloat
Description copied from interface:RedisSessionIncrements a hash field by a float.- Specified by:
hincrbyfloatin interfaceRedisSession- Parameters:
key- the keyfield- the field nameincrement- the amounth- receives the new value as a string
-
lpush
Description copied from interface:RedisSessionPushes values to the left (head) of a list.- Specified by:
lpushin interfaceRedisSession- Parameters:
key- the keyh- receives the new list lengthvalues- the values to push
-
rpush
Description copied from interface:RedisSessionPushes values to the right (tail) of a list.- Specified by:
rpushin interfaceRedisSession- Parameters:
key- the keyh- receives the new list lengthvalues- the values to push
-
lpop
Description copied from interface:RedisSessionPops a value from the left (head) of a list.- Specified by:
lpopin interfaceRedisSession- Parameters:
key- the keyh- receives the value or null if empty
-
rpop
Description copied from interface:RedisSessionPops a value from the right (tail) of a list.- Specified by:
rpopin interfaceRedisSession- Parameters:
key- the keyh- receives the value or null if empty
-
lrange
Description copied from interface:RedisSessionGets a range of elements from a list.- Specified by:
lrangein interfaceRedisSession- Parameters:
key- the keystart- the start index (0-based, negative from end)stop- the stop index (inclusive, negative from end)h- receives the elements
-
llen
Description copied from interface:RedisSessionGets the length of a list.- Specified by:
llenin interfaceRedisSession- Parameters:
key- the keyh- receives the length
-
lindex
Description copied from interface:RedisSessionGets an element by index.- Specified by:
lindexin interfaceRedisSession- Parameters:
key- the keyindex- the index (negative from end)h- receives the element or null
-
lset
Description copied from interface:RedisSessionSets an element by index.- Specified by:
lsetin interfaceRedisSession- Parameters:
key- the keyindex- the indexvalue- the new valueh- receives "OK"
-
ltrim
Description copied from interface:RedisSessionTrims a list to the specified range.- Specified by:
ltrimin interfaceRedisSession- Parameters:
key- the keystart- the start indexstop- the stop indexh- receives "OK"
-
lrem
Description copied from interface:RedisSessionRemoves elements from a list.- Specified by:
lremin interfaceRedisSession- Parameters:
key- the keycount- number to remove (0=all, positive=from head, negative=from tail)value- the value to removeh- receives the count removed
-
blpop
Description copied from interface:RedisSessionBlocking pop from the left (head) of one or more lists. Blocks until an element is available or the timeout expires.- Specified by:
blpopin interfaceRedisSession- Parameters:
timeout- the timeout in seconds (0 = block indefinitely)h- receives [key, value] array or null on timeoutkeys- the list keys to pop from
-
brpop
Description copied from interface:RedisSessionBlocking pop from the right (tail) of one or more lists. Blocks until an element is available or the timeout expires.- Specified by:
brpopin interfaceRedisSession- Parameters:
timeout- the timeout in seconds (0 = block indefinitely)h- receives [key, value] array or null on timeoutkeys- the list keys to pop from
-
blmove
public void blmove(String source, String destination, String whereFrom, String whereTo, double timeout, BulkResultHandler h) Description copied from interface:RedisSessionBlocking move of an element from one list to another (Redis 6.2+).- Specified by:
blmovein interfaceRedisSession- Parameters:
source- the source list keydestination- the destination list keywhereFrom- "LEFT" or "RIGHT"whereTo- "LEFT" or "RIGHT"timeout- the timeout in seconds (0 = block indefinitely)h- receives the moved element or null on timeout
-
sadd
Description copied from interface:RedisSessionAdds members to a set.- Specified by:
saddin interfaceRedisSession- Parameters:
key- the keyh- receives count of new members addedmembers- the members to add
-
srem
Description copied from interface:RedisSessionRemoves members from a set.- Specified by:
sremin interfaceRedisSession- Parameters:
key- the keyh- receives count of members removedmembers- the members to remove
-
smembers
Description copied from interface:RedisSessionGets all members of a set.- Specified by:
smembersin interfaceRedisSession- Parameters:
key- the keyh- receives the members
-
sismember
Description copied from interface:RedisSessionChecks if a value is a member of a set.- Specified by:
sismemberin interfaceRedisSession- Parameters:
key- the keymember- the member to checkh- receives true if member exists
-
scard
Description copied from interface:RedisSessionGets the number of members in a set.- Specified by:
scardin interfaceRedisSession- Parameters:
key- the keyh- receives the cardinality
-
spop
Description copied from interface:RedisSessionPops a random member from a set.- Specified by:
spopin interfaceRedisSession- Parameters:
key- the keyh- receives the member or null if empty
-
srandmember
Description copied from interface:RedisSessionGets a random member without removing it.- Specified by:
srandmemberin interfaceRedisSession- Parameters:
key- the keyh- receives the member or null if empty
-
zadd
Description copied from interface:RedisSessionAdds a member with a score to a sorted set.- Specified by:
zaddin interfaceRedisSession- Parameters:
key- the keyscore- the scoremember- the memberh- receives count of new members added
-
zscore
Description copied from interface:RedisSessionGets the score of a member.- Specified by:
zscorein interfaceRedisSession- Parameters:
key- the keymember- the memberh- receives the score or null if not found
-
zrange
Description copied from interface:RedisSessionGets members in a range by index.- Specified by:
zrangein interfaceRedisSession- Parameters:
key- the keystart- the start indexstop- the stop indexh- receives the members
-
zrangeWithScores
Description copied from interface:RedisSessionGets members in a range by index with scores.- Specified by:
zrangeWithScoresin interfaceRedisSession- Parameters:
key- the keystart- the start indexstop- the stop indexh- receives alternating member/score pairs
-
zrevrange
Description copied from interface:RedisSessionGets members in reverse order by index.- Specified by:
zrevrangein interfaceRedisSession- Parameters:
key- the keystart- the start indexstop- the stop indexh- receives the members
-
zrank
Description copied from interface:RedisSessionGets the rank of a member (0-based, lowest score first).- Specified by:
zrankin interfaceRedisSession- Parameters:
key- the keymember- the memberh- receives the rank or null if not found
-
zrem
Description copied from interface:RedisSessionRemoves members from a sorted set.- Specified by:
zremin interfaceRedisSession- Parameters:
key- the keyh- receives count of members removedmembers- the members to remove
-
zcard
Description copied from interface:RedisSessionGets the number of members in a sorted set.- Specified by:
zcardin interfaceRedisSession- Parameters:
key- the keyh- receives the cardinality
-
zincrby
Description copied from interface:RedisSessionIncrements a member's score.- Specified by:
zincrbyin interfaceRedisSession- Parameters:
key- the keyincrement- the amount to addmember- the memberh- receives the new score
-
subscribe
Description copied from interface:RedisSessionSubscribes to channels.After subscribing, the connection enters Pub/Sub mode and can only execute SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, PUNSUBSCRIBE, PING, and QUIT.
- Specified by:
subscribein interfaceRedisSession- Parameters:
h- receives messages and subscription confirmationschannels- the channels to subscribe to
-
psubscribe
Description copied from interface:RedisSessionSubscribes to channel patterns.- Specified by:
psubscribein interfaceRedisSession- Parameters:
h- receives messages and subscription confirmationspatterns- the glob-style patterns to subscribe to
-
unsubscribe
Description copied from interface:RedisSessionUnsubscribes from channels.- Specified by:
unsubscribein interfaceRedisSession- Parameters:
channels- the channels to unsubscribe from (empty = all)
-
punsubscribe
Description copied from interface:RedisSessionUnsubscribes from patterns.- Specified by:
punsubscribein interfaceRedisSession- Parameters:
patterns- the patterns to unsubscribe from (empty = all)
-
publish
Description copied from interface:RedisSessionPublishes a message to a channel.- Specified by:
publishin interfaceRedisSession- Parameters:
channel- the channelmessage- the messageh- receives the number of subscribers who received the message
-
publish
Description copied from interface:RedisSessionPublishes a binary message to a channel.- Specified by:
publishin interfaceRedisSession- Parameters:
channel- the channelmessage- the message bytesh- receives the number of subscribers who received the message
-
multi
Description copied from interface:RedisSessionMarks the start of a transaction.After MULTI, all commands are queued until EXEC is called.
- Specified by:
multiin interfaceRedisSession- Parameters:
h- receives "OK"
-
exec
Description copied from interface:RedisSessionExecutes all queued commands in a transaction.- Specified by:
execin interfaceRedisSession- Parameters:
h- receives array of results, or null if WATCH failed
-
discard
Description copied from interface:RedisSessionDiscards all queued commands.- Specified by:
discardin interfaceRedisSession- Parameters:
h- receives "OK"
-
watch
Description copied from interface:RedisSessionWatches keys for changes (optimistic locking).- Specified by:
watchin interfaceRedisSession- Parameters:
h- receives "OK"keys- the keys to watch
-
unwatch
Description copied from interface:RedisSessionUnwatches all keys.- Specified by:
unwatchin interfaceRedisSession- Parameters:
h- receives "OK"
-
eval
Description copied from interface:RedisSessionExecutes a Lua script.- Specified by:
evalin interfaceRedisSession- Parameters:
script- the Lua scriptnumKeys- the number of keyskeys- the keys (available as KEYS[1], KEYS[2], etc.)args- additional arguments (available as ARGV[1], ARGV[2], etc.)h- receives the script result
-
evalsha
Description copied from interface:RedisSessionExecutes a cached script by SHA1 hash.- Specified by:
evalshain interfaceRedisSession- Parameters:
sha1- the script SHA1 hashnumKeys- the number of keyskeys- the keysargs- additional argumentsh- receives the script result
-
xadd
Description copied from interface:RedisSessionAppends an entry to a stream.- Specified by:
xaddin interfaceRedisSession- Parameters:
key- the stream keyid- the entry ID ("*" for auto-generated)h- receives the entry IDfieldsAndValues- alternating field names and values
-
xlen
Description copied from interface:RedisSessionReturns the number of entries in a stream.- Specified by:
xlenin interfaceRedisSession- Parameters:
key- the stream keyh- receives the count
-
xrange
Description copied from interface:RedisSessionReturns a range of entries from a stream.- Specified by:
xrangein interfaceRedisSession- Parameters:
key- the stream keystart- the start ID ("-" for minimum)end- the end ID ("+" for maximum)h- receives the entries
-
xrange
Description copied from interface:RedisSessionReturns a range of entries with a count limit.- Specified by:
xrangein interfaceRedisSession- Parameters:
key- the stream keystart- the start ID ("-" for minimum)end- the end ID ("+" for maximum)count- the maximum number of entriesh- receives the entries
-
xrevrange
Description copied from interface:RedisSessionReturns a range of entries in reverse order.- Specified by:
xrevrangein interfaceRedisSession- Parameters:
key- the stream keyend- the end ID ("+" for maximum)start- the start ID ("-" for minimum)h- receives the entries
-
xrevrange
Description copied from interface:RedisSessionReturns a range of entries in reverse order with a count limit.- Specified by:
xrevrangein interfaceRedisSession- Parameters:
key- the stream keyend- the end ID ("+" for maximum)start- the start ID ("-" for minimum)count- the maximum number of entriesh- receives the entries
-
xread
Description copied from interface:RedisSessionReads entries from one or more streams, optionally blocking.- Specified by:
xreadin interfaceRedisSession- Parameters:
count- the maximum number of entries per stream (0 for default)blockMillis- the block timeout in milliseconds (negative to not block)h- receives the entries per streamkeysAndIds- alternating stream keys and IDs
-
xtrim
Description copied from interface:RedisSessionTrims a stream to approximately the specified length.- Specified by:
xtrimin interfaceRedisSession- Parameters:
key- the stream keymaxLen- the maximum lengthh- receives the number of entries removed
-
xack
Description copied from interface:RedisSessionAcknowledges one or more stream entries for a consumer group.- Specified by:
xackin interfaceRedisSession- Parameters:
key- the stream keygroup- the consumer group nameh- receives the count of acknowledged entriesids- the entry IDs to acknowledge
-
xgroupCreate
Description copied from interface:RedisSessionCreates a consumer group for a stream.- Specified by:
xgroupCreatein interfaceRedisSession- Parameters:
key- the stream keygroup- the consumer group nameid- the starting entry ID ("$" for new entries only, "0" for all)h- receives "OK"
-
xgroupDestroy
Description copied from interface:RedisSessionDeletes a consumer group.- Specified by:
xgroupDestroyin interfaceRedisSession- Parameters:
key- the stream keygroup- the consumer group nameh- receives the result
-
xpending
Description copied from interface:RedisSessionReturns the number of pending entries for a consumer group.- Specified by:
xpendingin interfaceRedisSession- Parameters:
key- the stream keygroup- the consumer group nameh- receives the pending entry information
-
info
Description copied from interface:RedisSessionGets server information.- Specified by:
infoin interfaceRedisSession- Parameters:
h- receives the info string
-
info
Description copied from interface:RedisSessionGets server information for a specific section.- Specified by:
infoin interfaceRedisSession- Parameters:
section- the section nameh- receives the info string
-
dbsize
Description copied from interface:RedisSessionGets the number of keys in the current database.- Specified by:
dbsizein interfaceRedisSession- Parameters:
h- receives the count
-
flushdb
Description copied from interface:RedisSessionFlushes the current database.- Specified by:
flushdbin interfaceRedisSession- Parameters:
h- receives "OK"
-
flushall
Description copied from interface:RedisSessionFlushes all databases.- Specified by:
flushallin interfaceRedisSession- Parameters:
h- receives "OK"
-
time
Description copied from interface:RedisSessionReturns the server time.- Specified by:
timein interfaceRedisSession- Parameters:
h- receives array of [unix timestamp seconds, microseconds]
-
command
Description copied from interface:RedisSessionSends a raw command with string arguments.Use this for commands not covered by specific methods.
- Specified by:
commandin interfaceRedisSession- Parameters:
h- receives the resultcommand- the command nameargs- the arguments
-
command
Description copied from interface:RedisSessionSends a raw command with byte array arguments.- Specified by:
commandin interfaceRedisSession- Parameters:
h- receives the resultcommand- the command nameargs- the arguments as byte arrays
-