This busmod allows provides access to a redis server. To use this busmod you must be have a redis server running on your network.
This is a worker busmod and must be started as a worker verticle.
This busmod requires a redis server to be available on the network.
The module name is redis-client
.
The redis-client busmod takes the following configuration:
{
"address": <address>,
"host": <host>,
"port": <port>
}
For example:
{
"address": "test.my_redisclient",
"host": "192.168.1.100",
"port": 6379,
}
Let's take a look at each field in turn:
address
The main address for the busmod. Every busmod has a main address. Defaults to redis-client
.host
Host name or ip address of the redis serve. Defaults to localhost
.port
Port at which the redis server is listening. Defaults to 27017
.For example:
eb.send('vertx.redis-client', {command: "set", key: 'name', value: 'vertx'});
The call consists of two parts, the redis command and the parameters for the command:
command : the redis command that should be called
Parameters key : key parameter value : value parameter
The Parameters are command specific and are mostly named after the official redis command documentation (http://redis.io/commands).
The error response looks like this:
{
"status": "ok",
"value":
Value is the value returned by the redis server (http://redis.io/topics/protocol).
The error response looks like this:
{
"status": "error",
"message":
Message is just the error message thrown by jedis.
The busmod supports the following redis commands
http://redis.io/commands#connection
Change the selected database for the current connection
Command : select Parameter : index (int)
Return : String (Status reply)
Example request: { command : "select", index : 1 } Example response: { status : "ok", value : "ok" }
http://redis.io/commands#generic
Determine if a key exists
Return : Boolean reply: true if the key exists. false if the key does not exist.
Example request:
{
command : "exists",
key : "key1"
}
Example response:
{
status : "ok",
value : true
}
Delete a key
Return : Integer reply: The number of keys that were removed
Example request:
{
command : "del",
keys : [
"key1"
]
}
Example response:
{
status : "ok",
value : 1
}
Find all keys matching the given pattern.
Return : Multi-bulk reply: list of keys matching pattern.
Example request:
{
command : "keys",
pattern : "h?llo"
}
Example response:
{
status : "ok",
value : [
"hello",
"hallo"
]
}
Supported glob-style patterns:
Set a key's time to live in seconds
Return : Integer reply: 1 if the timeout was set. 0 if key does not exist or the timeout could not be set.
Example request:
{
command : "expire",
key : "the_key"
seconds : 60
}
Example response:
{
status : "ok",
value : 1
}
Set the expiration for a key as a UNIX timestamp
Return : Integer reply: 1 if the timeout was set. 0 if key does not exist or the timeout could not be set.
Example request:
{
command : "expireat",
key : "the_key"
timestamp : 1293840000
}
Example response:
{
status : "ok",
value : 1
}
Move a key to another database
Return : Integer reply: 1 if key was moved. 0 if key was not moved.
Example request:
{
command : "move",
key : "the_key"
index : 1
}
Example response:
{
status : "ok",
value : 1
}
Remove the expiration from a key
Return : Integer reply: 1 if the timeout was removed. 0 if key does not exist or does not have an associated timeout.
Example request:
{
command : "persist",
key : "the_key"
}
Example response:
{
status : "ok",
value : 1
}
Return a random key from the keyspace
Return : Bulk reply: the random key, or nil when the database is empty.
Example request:
{
command : "randomkey"
}
Example response:
{
status : "ok",
value : "a_random_key"
}
Rename a key
Return : Status code reply
Example request:
{
command : "rename",
key : "the_key"
newkey : "new_key"
}
Example response:
{
status : "ok",
value : "OK"
}
Rename a key, only if the new key does not exist
Return : Integer reply 1 if key was renamed to newkey. 0 if newkey already exists.
Example request:
{
command : "renamenx",
key : "the_key"
newkey : "new_key"
}
Example response:
{
status : "ok",
value : 1
}
Sort the elements in a list, set or sorted set
Return : Multi-bulk reply: list of sorted elements.
Example request:
{
command : "sort",
key : "the_key",
alpha : true,
order : "asc",
by : "weight_*",
start : 0,
count : 10
}
order values: asc : sorted in ascending order desc : sorted in descending order
Example response:
{
status : "ok",
value : [
"value1",
"value2"
]
}
Get the time to live for a key
Return : Integer reply: TTL in seconds or -1 when key does not exist or does not have a timeout.
Example request:
{
command : "ttl",
key : "the_key"
}
Example response:
{
status : "ok",
value : 60
}
Determine the type stored at key
Return : Status code reply: type of key, or none when key does not exist.
Example request:
{
command : "type",
key : "the_key"
}
Example response:
{
status : "ok",
value : "string"
}
posible types: string, list, set ...
http://redis.io/commands#string
Append a value to a key
Return : Integer reply: the length of the string after the append operation.
Example request:
{
command : "append",
key : "the_key",
value : "to_append"
}
Example response:
{
status : "ok",
value : 16
}
Decrement the integer value of a key by the given number
Return : Integer reply: the value of key after the decrement
Example request:
{
command : "decrby",
key : "the_key",
decrement : 5
}
Example response:
{
status : "ok",
value : 5
}
Decrement the integer value of a key by one
Return : Integer reply: the value of key after the decrement
Example request:
{
command : "decr",
key : "the_key"
}
Example response:
{
status : "ok",
value : 6
}
Returns the bit value at offset in the string value stored at key
Return : Integer reply: the bit value stored at offset.
Example request:
{
command : "getbit",
key : "the_key",
offset : 1
}
Example response:
{
status : "ok",
value : 0
}
Get the value of a key
Return : Bulk reply: the value of key, or nil when key does not exist.
Example request:
{
command : "get",
key : "the_key"
}
Example response:
{
status : "ok",
value : "the_value"
}
Get a substring of the string stored at a key
Return : Bulk reply: the substring of the value
Example request:
{
command : "getrange",
key : "the_key",
start : 0,
end : 10
}
Example response:
{
status : "ok",
value : "ing"
}
Set the string value of a key and return its old value
Return : Bulk reply: the old value stored at key, or nil when key did not exist.
Example request:
{
command : "getset",
key : "the_key",
value : "new_value"
}
Example response:
{
status : "ok",
value : "old_value"
}
Increment the integer value of a key by the given amount
Return : Integer reply: the value of key after the increment
Example request:
{
command : "incrby",
key : "the_key",
increment : 5
}
Example response:
{
status : "ok",
value : 16
}
Increment the integer value of a key by one
Return : Integer reply: the value of key after the increment
Example request:
{
command : "incr",
key : "the_key"
}
Example response:
{
status : "ok",
value : 17
}
Get the values of all the given keys
Return : Multi-bulk reply: list of values at the specified keys.
Example request:
{
command : "append",
key : [
"key_1", "key_2"
]
}
Example response:
{
status : "ok",
value : [
"value_1", "value_2"
]
}
Set multiple keys to multiple values
Return : Status code reply: always OK since MSET can't fail.
Example request:
{
command : "mset",
keyvalues : {
"key_1" : "value_1",
"key_2" : "value_2"
}
}
Example response:
{
value : "OK"
status : "ok",
}
Sets or clears the bit at offset in the string value stored at key
Return : Integer reply: the original bit value stored at offset.
Example request:
{
command : "setbit",
key : "the_key",
offset : 5,
value: 1
}
Example response:
{
status : "ok",
value : false
}
Set the string value of a key
Return : Status code reply: always OK since SET can't fail.
Example request:
{
command : "set",
key : "the_key",
value : "the_value"
}
Example response:
{
status : "ok",
value : "OK"
}
Set the value and expiration of a key
Return : Status code reply
Example request:
{
command : "setex",
key : "the_key",
value : "the_value"
seconds : 60
}
Example response:
{
status : "ok",
value : OK
}
Set the value of a key, only if the key does not exist
Return : Integer reply, specifically:
Example request:
{
command : "setnx",
key : "the_key",
value : "the_value"
}
Example response:
{
status : "ok",
value : 1
}
Overwrite part of a string at key starting at the specified offset
Return : Integer reply: the length of the string after it was modified by the command.
Example request:
{
command : "setrange",
key : "the_key",
value : "the_value",
offset : 5
}
Example response:
{
status : "ok",
value : 14
}
Get the length of the value stored in a key
Return : Integer reply: the length of the string at key, or 0 when key does not exist.
Example request:
{
command : "strlen",
key : "the_key"
}
Example response:
{
status : "ok",
value : 16
}
Remove and get the first element in a list, or block until one is available
Remove and get the last element in a list, or block until one is available
Get an element from a list by its index
Insert an element before or after another element in a list
Get the length of a list
Remove and get the first element in a list
Append one or multiple values to a list
Prepend a value to a list, only if the list exists
Get a range of elements from a list
Remove elements from a list
Set the value of an element in a list by its index
Trim a list to the specified range
Remove and get the last element in a list
Remove the last element in a list, append it to another list and return it
Append one or multiple values to a list
Append a value to a list, only if the list exists
Add one or more members to a set
Get the number of members in a set
Subtract multiple sets
Subtract multiple sets and store the resulting set in a key
Intersect multiple sets
Intersect multiple sets and store the resulting set in a key
Determine if a given value is a member of a set
Get all the members in a set
Move a member from one set to another
Remove and return a random member from a set
Get a random member from a set
Remove one or more members from a set
Add multiple sets
Add multiple sets and store the resulting set in a key
Add one or more members to a sorted set, or update its score if it already exists
Get the number of members in a sorted set
Count the members in a sorted set with scores within the given values
Increment the score of a member in a sorted set
Intersect multiple sorted sets and store the resulting sorted set in a new key
Return a range of members in a sorted set, by score
Return a range of members in a sorted set, by index
Determine the index of a member in a sorted set
Remove one or more members from a sorted set
Remove all members in a sorted set within the given indexes
Remove all members in a sorted set within the given scores
Return a range of members in a sorted set, by score, with scores ordered from high to low
Return a range of members in a sorted set, by index, with scores ordered from high to low
Determine the index of a member in a sorted set, with scores ordered from high to low
Get the score associated with the given member in a sorted set
Add multiple sorted sets and store the resulting sorted set in a new key