Redis
Talk to a Redis server: strings, keys with expiry, counters, hashes, lists, sets, publish, any command and pipelines. Typical uses: share a cache or counters with other applications, publish events.
redis pingredis setredis setredis getredis delredis existsredis expireredis ttlredis incrredis incrredis hsetredis hgetredis hgetallredis keysredis keysredis lpushredis rpushredis lrangeredis lpopredis rpopredis saddredis smembersredis publishredis commandredis pipeline

redis ping <config>


Description

    Test the connection and the authentication. Returns PONG

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
admin
redis ping "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}"
mentdb
PONG

redis set <config> <key> <value>


Description

    Set a value. Returns OK

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    value:   The value - String - required
admin
redis set "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "greeting" "héllo €"
mentdb
OK

redis set <config> <key> <value> <json_params>


Description

    Set with parameters: ex (seconds) or px (milliseconds), nx (only if absent) or xx (only if present). Returns OK, or null if the condition failed

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    value:   The value - String - required
    json_params:   The parameters - String - required
admin
redis set "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "lock:job" "worker-1" "{\"ex\": 30, \"nx\": true}"
mentdb
OK
a lock of 30 s: second call, already taken (fixed result: local fake Redis server, not a real Redis)
admin
redis set "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "lock:job" "worker-2" "{\"px\": 30000, \"nx\": true}"
mentdb
null

redis get <config> <key>


Description

    Read a value; null if the key does not exist

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis get "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "greeting"
mentdb
héllo €
no such key (fixed result: local fake Redis server, not a real Redis)
admin
redis get "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "nothing"
mentdb
null
in the database 5 (SELECT) (fixed result: local fake Redis server, not a real Redis)
admin
redis get "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\", \"db\": 5, \"timeout_ms\": 3000}" "greeting"
mentdb
null

redis del <config> <json_keys_or_key>


Description

    Delete keys. Returns the number of deleted keys

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    json_keys_or_key:   A key, or a JSON array of keys (a text that is not a JSON array of strings is one key) - String - required
admin
redis del "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "lock:job"
mentdb
1
a list (fixed result: local fake Redis server, not a real Redis)
admin
redis del "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "[\"a\", \"b\"]"
mentdb
0

redis exists <config> <json_keys_or_key>


Description

    The number of existing keys among those given

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    json_keys_or_key:   A key, or a JSON array of keys (a text that is not a JSON array of strings is one key) - String - required
admin
redis exists "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "greeting"
mentdb
1
a list (fixed result: local fake Redis server, not a real Redis)
admin
redis exists "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "[\"greeting\", \"nothing\"]"
mentdb
1

redis expire <config> <key> <seconds>


Description

    Set the time to live of a key. Returns 1, or 0 if the key does not exist

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    seconds:   The seconds (positive) - Number - required
admin
redis expire "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "greeting" 60
mentdb
1

redis ttl <config> <key>


Description

    The seconds to live of a key; -1: no expiry; -2: no key

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis ttl "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "nothing"
mentdb
-2

redis incr <config> <key>


Description

    Increment an integer by 1 (0 if absent). Returns the new value

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis incr "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "visits"
mentdb
1

redis incr <config> <key> <by>


Description

    Increment by an integer, which can be negative

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    by:   The increment - Number - required
admin
redis incr "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "visits" 10
mentdb
11

redis hset <config> <key> <json_object>


Description

    Set fields of a hash from a JSON object (numbers and booleans as text, objects and arrays as JSON text). Returns the number of new fields

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    json_object:   The fields - String - required
admin
redis hset "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "user:1" "{\"name\": \"Zoé\", \"age\": 31}"
mentdb
2

redis hget <config> <key> <field>


Description

    A field of a hash; null if absent

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    field:   The field - String - required
admin
redis hget "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "user:1" "name"
mentdb
Zoé

redis hgetall <config> <key>


Description

    All the fields of a hash as a JSON object ({} if the key does not exist)

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis hgetall "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "user:1"
mentdb
{"name": "Zoé", "age": "31"}

redis keys <config> <pattern>


Description

    The keys matching a pattern as a sorted JSON array, 10000 at most: always with SCAN (never KEYS, which blocks the server)

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    pattern:   The pattern: * ? [abc] - String - required
admin
redis keys "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "*"
mentdb
["greeting", "user:1", "visits"]

redis keys <config> <pattern> <json_params>


Description

    Keys with parameters: limit (10000, 1000000 at most; the scan stops at the limit, the result may then be cut)

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    pattern:   The pattern - String - required
    json_params:   The parameters - String - required
admin
redis keys "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "user:*" "{\"limit\": 2}"
mentdb
["user:1"]

redis lpush <config> <key> <json_values>


Description

    Add values at the head of a list, one after the other. Returns the length of the list

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    json_values:   The values as a JSON array (numbers and booleans as text, objects and arrays as JSON text) - String - required
admin
redis lpush "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "queue" "[\"b\", \"a\"]"
mentdb
2

redis rpush <config> <key> <json_values>


Description

    Add values at the tail of a list. Returns the length of the list

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    json_values:   The values as a JSON array (numbers and booleans as text, objects and arrays as JSON text) - String - required
admin
redis rpush "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "queue" "[\"c\", 4]"
mentdb
4

redis lrange <config> <key> <start> <stop>


Description

    A part of a list as a JSON array; negative positions count from the end

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    start:   The first position - Number - required
    stop:   The last position, included - Number - required
admin
redis lrange "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "queue" 0 -1
mentdb
["a", "b", "c", "4"]

redis lpop <config> <key>


Description

    Remove and return the head of a list; null if empty

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis lpop "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "queue"
mentdb
a

redis rpop <config> <key>


Description

    Remove and return the tail of a list; null if empty

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis rpop "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "queue"
mentdb
4

redis sadd <config> <key> <json_values>


Description

    Add values to a set. Returns the number of new values

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
    json_values:   The values as a JSON array (numbers and booleans as text, objects and arrays as JSON text) - String - required
admin
redis sadd "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "tags" "[\"red\", \"blue\", \"red\"]"
mentdb
2

redis smembers <config> <key>


Description

    The values of a set as a sorted JSON array

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    key:   The key - String - required
admin
redis smembers "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "tags"
mentdb
["blue", "red"]

redis publish <config> <channel> <message>


Description

    Publish a message on a channel. Returns the number of subscribers that received it

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    channel:   The channel - String - required
    message:   The message - String - required
admin
redis publish "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "events" "file ready"
mentdb
3

redis command <config> <json_args>


Description

    Any command as a JSON array: a text, an integer or null as is, an array as JSON (inner errors as {"error": ...}). An error reply is thrown

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    json_args:   The name and the arguments, like ["GET", "key"] - String - required
admin
redis command "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "[\"GET\", \"greeting\"]"
mentdb
héllo €
an array (fixed result: local fake Redis server, not a real Redis)
admin
redis command "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "[\"LRANGE\", \"queue\", 0, -1]"
mentdb
["b", "c"]

redis pipeline <config> <json_commands>


Description

    Several commands on one connection, sent together: a JSON array of the results in order, an error stays in its place as {"error": ...} and does not stop the others

Parameters

    config:   The Redis configuration as JSON: host (127.0.0.1), port (6379), username, password (the name of a secret: secret set), db, tls (false; true: certificate and host name checked with the trust store of the JDK), allow_plain (false: a password or a username without tls is refused unless the host is localhost, 127.0.0.1 or ::1; true: accept to send them in clear), timeout_ms (10000) - String - required
    json_commands:   An array of commands, like [["SET", "a", "1"], ["GET", "a"]] - String - required
admin
redis pipeline "{\"host\": \"127.0.0.1\", \"password\": \"redis_password\"}" "[[\"SET\", \"a\", \"1\"], [\"NOPE\"], [\"GET\", \"a\"], [\"GET\", \"nothing\"], [\"INCR\", \"n\"]]"
mentdb
["OK", {"error": "ERR unknown command 'NOPE', with args beginning with: ''"}, "1", null, 1]