Redis is an open-source, networked, in-memory, persistent, journaled, key-value data store. Provides Redis connectivity to Mule:
- Supports Redis Publish/Subscribe model for asynchronous message exchanges,
- Allows direct reading and writing operations in Redis collections,
- Allows using Redis as a ObjectStore for Mule components that require persistence.
Additional Info
Requires Mule Enterprise License |
Yes |
Requires Entitlement |
No |
Mule Version |
3.6.0 or higher |
Configs
Configuration
<redis:config>
Configuration
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
name |
The name of this configuration. With this name can be later referenced. |
x |
||
host |
Redis host. Use this field when you want to access you Redis server that is not part of a cluster through connector. |
localhost |
|
|
clusterHosts |
Redis cluster hosts separated by comma and having format host:port. Use this field when you want to access you Redis cluster through connector. |
|
||
port |
int |
Redis port. The port on which your non cluster server is running. |
6379 |
|
connectionTimeout |
int |
Connection timeout in milliseconds. |
2000 |
|
password |
Redis password. Set this in case that the server requires authentication. |
|
||
defaultPartitionName |
The PartitionableObjectStore partition to use in case methods from ObjectStore are used. |
|
||
entryTTL |
The default time to live to be set on keys stored through connector. |
|
||
poolConfig |
JedisPoolConfig |
Object pool configuration. |
|
Processors
Set
<redis:set>
Set key to hold the payload. If key already holds a value, it is overwritten, regardless of its type as long as ifNotExists is false.
XML Sample
<redis:set config-ref="Redis_configuration" key="my_key" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
value |
The value to set. |
#[payload] |
|
|
key |
Key used to store payload |
x |
||
expire |
Set a timeout on the specified key. After the timeout the key will be automatically deleted by the server. A key with an associated timeout is said to be volatile in Redis terminology. |
|
||
ifNotExists |
boolean |
If true, then execute SETNX on the Redis server, otherwise execute SET |
false |
|
Returns
Return Java Type | Description |
---|---|
byte[] |
If the key already exists and ifNotExists is true, null is returned. Otherwise the message is returned. |
Get
<redis:get>
Get the value of the specified key. If the key does not exist null is returned.
XML Sample
<redis:get config-ref="Redis_configuration" key="my_key"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for GET |
x |
Returns
Return Java Type | Description |
---|---|
byte[] |
A byte array with the content of the key |
Exists
<redis:exists>
Test if the specified key exists.
XML Sample
<redis:exists config-ref="Redis_configuration" key="my_key" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for EXISTS |
x |
Increment
<redis:increment>
Increments the number stored at key by step. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains data that can not be represented as integer.
XML Sample
<redis:increment config-ref="Redis_configuration" key="my_key"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for INCR. |
x |
||
step |
long |
Step used for the increment. |
1 |
|
Decrement
<redis:decrement>
Decrements the number stored at key by step. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains data that can not be represented as integer.
XML Sample
<redis:decrement config-ref="Redis_configuration" key="my_key"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for DECR. |
x |
||
step |
long |
Step used for the increment. |
1 |
|
Set in hash
<redis:hash-set>
Set the specified hash field to the message payload. If key does not exist, a new key holding a hash is created as long as ifNotExists is true.
XML Sample
<redis:hash-set config-ref="Redis_configuration" key="my_key" field="my_field" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
value |
The value to set. |
#[payload] |
|
|
key |
Key that will be used for HSET |
x |
||
field |
Field that will be used for HSET |
x |
||
ifNotExists |
boolean |
If true execute HSETNX otherwise HSET |
false |
|
Returns
Return Java Type | Description |
---|---|
byte[] |
If the field already exists and ifNotExists is true, null is returned, otherwise if a new field is created the message is returned. |
Get all from hash
<redis:hash-get-all>
Get all fields and values of the hash stored at the specified key. If the field or the hash don't exist, null is returned.
XML Sample
<redis:hash-get-all config-ref="Redis_configuration" key="my_key" field="my_field" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for HGETALL |
x |
Get from hash
<redis:hash-get>
Get the value stored at the specified field in the hash at the specified key. If the field or the hash don't exist, null is returned.
XML Sample
<redis:hash-get config-ref="Redis_configuration" key="my_key" field="my_field" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for HGET |
x |
||
field |
Field that will be used for HGET |
x |
Returns
Return Java Type | Description |
---|---|
byte[] |
The value or null. |
Increment hash
<redis:hash-increment>
Increments the number stored at field in the hash stored at key by increment. If key does not exist, a new key holding a hash is created. If field does not exist the value is set to 0 before the operation is performed.
XML Sample
<redis:hash-increment config-ref="Redis_configuration" key="my_key" field="my_field" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for HGET |
x |
||
field |
Field that will be used for HGET |
x |
||
step |
long |
Step used for the increment. |
1 |
|
Push to list
<redis:list-push>
Push the message payload to the desired side (LEFT or RIGHT) of the list stored at the specified key. If key does not exist, a new key holding a list is created as long as ifExists is not true.
XML Sample
<redis:list-push config-ref="Redis_configuration" key="my_key" side="RIGHT" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
value |
The value to push. |
#[payload] |
|
|
key |
Key that will be used for LPUSH/RPUSH/LPUSHX/RPUSH |
x |
||
side |
The side where to push the payload, either LEFT or RIGHT |
x |
||
ifExists |
boolean |
If true execute LPUSHX/RPUSH otherwise LPUSH/RPUSH |
false |
|
Returns
Return Java Type | Description |
---|---|
byte[] |
If the key doesn't already exist and ifExists is true, null is returned. Otherwise the message is returned. |
Pop from list
<redis:list-pop>
Pop a value from the desired side of the list stored at the specified key.
XML Sample
<redis:list-pop config-ref="Redis_configuration" key="my_key" side="RIGHT" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for LPOP/RPOP |
x |
||
side |
The side where to pop the value from, either LEFT or RIGHT |
x |
Returns
Return Java Type | Description |
---|---|
byte[] |
The popped value or null if either the list is empty or no list exists at the key |
Add to set
<redis:set-add>
Add the message payload to the set stored at the specified key. If key does not exist, a new key holding a set is created.
XML Sample
<redis:set-add config-ref="Redis_configuration" key="my_key" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
value |
The value to set. |
#[payload] |
|
|
key |
Key that will be used for SADD |
x |
||
mustSucceed |
boolean |
If true, ensures that adding to the set was successful (ie no pre-existing identical value in the set) |
false |
|
Returns
Return Java Type | Description |
---|---|
byte[] |
If no new entry has been added to the set and mustSucceed is true, null is returned. Otherwise the message is returned. |
Pop from set
<redis:set-pop>
Pops a random value from the set stored at the specified key.
XML Sample
<redis:set-pop config-ref="Redis_configuration" key="my_key"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for SPOP |
x |
Returns
Return Java Type | Description |
---|---|
byte[] |
The popped value or null if either the set is empty or no set exists at the key |
Random member from set
<redis:set-fetch-random-member>
Reads a random value from the set stored at the specified key.
XML Sample
<redis:set-fetch-random-member config-ref="Redis_configuration" key="my_key"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for SRANDMEMBER |
x |
Returns
Return Java Type | Description |
---|---|
byte[] |
The random value or null if either the set is empty or no set exists at the key |
Add to sorted set
<redis:sorted-set-add>
Add the message payload with the desired score to the sorted set stored at the specified key. If key does not exist, a new key holding a sorted set is created.
XML Sample
<redis:sorted-set-add config-ref="Redis_configuration" key="my_key" score="123" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
value |
The value to set. |
#[payload] |
|
|
key |
Key that will be used for ZADD |
x |
||
score |
double |
Score to use for the value |
x |
|
mustSucceed |
boolean |
If true, ensures that adding to the sorted set was successful (ie no pre-existing identical value in the set) |
false |
|
Returns
Return Java Type | Description |
---|---|
byte[] |
If no new entry has been added to the sorted set and mustSucceed is true, null is returned. Otherwise the message is returned. |
Get range by index
<redis:sorted-set-select-range-by-index>
Retrieve a range of values from the sorted set stored at the specified key. The range of values is defined by indices in the sorted set and sorted as desired.
XML Sample
<redis:sorted-set-select-range-by-index config-ref="Redis_configuration" key="my_key" start="0" end="-1" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for ZRANGE/ZREVRANGE |
x |
||
start |
int |
Range start index |
x |
|
end |
int |
Range end index |
x |
|
order |
Index order for sorting the range, either ASCENDING or DESCENDING |
ASCENDING |
|
Returns
Return Java Type | Description |
---|---|
the values in the specified range in the desired order as set byte arrays |
Get range by score
<redis:sorted-set-select-range-by-score>
Retrieve a range of values from the sorted set stored at the specified key. The range of values is defined by scores in the sorted set and sorted as desired.
XML Sample
<redis:sorted-set-select-range-by-score config-ref="Redis_configuration" key="my_key" min="0.5" max="10" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
Key that will be used for ZRANGEBYSCORE/ZREVRANGEBYSCORE |
x |
||
min |
double |
Range start score |
x |
|
max |
double |
Range end score |
x |
|
order |
Score order for sorting the range, either ASCENDING or DESCENDING |
ASCENDING |
|
Returns
Return Java Type | Description |
---|---|
the values in the specified range in the desired order as set of byte arrays |
Increment sorted set
<redis:sorted-set-increment>
Increments the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sorted set with the specified member as its sole member is created.
XML Sample
<redis:sorted-set-increment config-ref="Redis_configuration" key="my_key" step="3.14" value="my_value"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
value |
The value to set. |
#[payload] |
|
|
key |
the key in the sorted set. |
x |
||
step |
double |
the step to use to increment the score. |
x |
Expire
<redis:expire>
Set a timeout on the specified key.
XML Sample
<redis:expire config-ref="Redis_configuration" key="my_key" seconds="20" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
the key in the sorted set. |
x |
||
seconds |
int |
the time to live in seconds. |
x |
Expire at
<redis:expire-at>
Set a timeout in the form of a UNIX timestamp (Number of seconds elapsed since 1 Jan 1970) on the specified key.
XML Sample
<redis:expire-at config-ref="Redis_configuration" key="my_key" unixTime="1293840000"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
the key in the sorted set. |
x |
||
unixTime |
long |
the UNIX timestamp in seconds. |
x |
Persist
<redis:persist>
Undo an expire or expireAt ; turning the volatile key into a normal key.
XML Sample
<redis:persist config-ref="Redis_configuration" key="my_key"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
the key in the sorted set. |
x |
Get ttl
<redis:get-ttl>
Get the remaining time to live in seconds of a volatile key.
XML Sample
<redis:get-ttl config-ref="Redis_configuration" key="my_key" />
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
key |
the key in the sorted set. |
x |
Returns
Return Java Type | Description |
---|---|
the remaining time to live in seconds, -2 when key does not exist or -1 when key does not have a timeout. |
Publish
<redis:publish>
Publish the message payload to the specified channel.
XML Sample
<redis:publish config-ref="Redis_configuration" channel="my_channel_name" message="my_message" mustSucceed="false"/>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
message |
The message to publish. |
#[payload] |
|
|
channel |
Destination of the published message |
x |
||
mustSucceed |
boolean |
Enforces the fact that the message must have been delivered to at least one consumer |
false |
|
Returns
Return Java Type | Description |
---|---|
byte[] |
If no consumer is subscribed to the channel and mustSucceed is true, null is returned. Otherwise the message is returned. |
Sources
Subscribe
<redis:subscribe>
Subscribe to the specified channels.
XML Sample
<redis:subscribe config-ref="Redis_configuration">
<redis:channels>
<redis:channel>"my_channel_name_1"</redis:channel>
<redis:channel>"my_channel_name_2"</redis:channel>
</redis:channels>
</redis:subscribe>
Attributes
Name | Java Type | Description | Default Value | Required |
---|---|---|---|---|
config-ref |
Specify which config to use |
x |
||
channels |
A list of channel names or globbing patterns. |
x |
||
callback |
SourceCallback |
Called when messages arrive in any of the specified channels. |
x |
Returns
Return Java Type | Description |
---|---|
void |