#[derive(Debug, Clone, Copy)]
pub struct Spec {
pub name: &'static str,
pub arity: i32,
pub flags: &'static [&'static str],
pub first_key: i32,
pub last_key: i32,
pub step: i32,
pub acl: &'static [&'static str],
pub since: &'static str,
pub complexity: &'static str,
pub summary: &'static str,
pub group: &'static str,
}
const READ_FAST: &[&str] = &["readonly", "fast"];
const WRITE_FAST_OOM: &[&str] = &["write", "denyoom", "fast"];
const WRITE_OOM: &[&str] = &["write", "denyoom"];
const AC_READ_FAST: &[&str] = &["@read", "@string", "@fast"];
const AC_READ_SLOW: &[&str] = &["@read", "@string", "@slow"];
const AC_WRITE_FAST: &[&str] = &["@write", "@string", "@fast"];
const AC_WRITE_SLOW: &[&str] = &["@write", "@string", "@slow"];
const WRITE_FAST: &[&str] = &["write", "fast"];
const AC_SET_READ_FAST: &[&str] = &["@read", "@set", "@fast"];
const AC_SET_READ_SLOW: &[&str] = &["@read", "@set", "@slow"];
const AC_SET_WRITE_FAST: &[&str] = &["@write", "@set", "@fast"];
const AC_SET_WRITE_SLOW: &[&str] = &["@write", "@set", "@slow"];
const AC_HASH_READ_FAST: &[&str] = &["@read", "@hash", "@fast"];
const AC_HASH_READ_SLOW: &[&str] = &["@read", "@hash", "@slow"];
const AC_HASH_WRITE_FAST: &[&str] = &["@write", "@hash", "@fast"];
const READ_SLOW: &[&str] = &["readonly"];
const WRITE_SLOW: &[&str] = &["write"];
const AC_LIST_READ_FAST: &[&str] = &["@read", "@list", "@fast"];
const AC_LIST_READ_SLOW: &[&str] = &["@read", "@list", "@slow"];
const AC_LIST_WRITE_FAST: &[&str] = &["@write", "@list", "@fast"];
const AC_LIST_WRITE_SLOW: &[&str] = &["@write", "@list", "@slow"];
const AC_LIST_WRITE_BLOCKING: &[&str] = &["@write", "@list", "@slow", "@blocking"];
const AC_ZSET_READ_FAST: &[&str] = &["@read", "@sortedset", "@fast"];
const AC_ZSET_READ_SLOW: &[&str] = &["@read", "@sortedset", "@slow"];
const AC_ZSET_WRITE_FAST: &[&str] = &["@write", "@sortedset", "@fast"];
const AC_ZSET_WRITE_SLOW: &[&str] = &["@write", "@sortedset", "@slow"];
const AC_ZSET_BLOCKING_FAST: &[&str] = &["@write", "@sortedset", "@fast", "@blocking"];
const AC_ZSET_BLOCKING_SLOW: &[&str] = &["@write", "@sortedset", "@slow", "@blocking"];
const AC_ARRAY_READ_FAST: &[&str] = &["@read", "@array", "@fast"];
const AC_ARRAY_READ_SLOW: &[&str] = &["@read", "@array", "@slow"];
const AC_ARRAY_WRITE_FAST: &[&str] = &["@write", "@array", "@fast"];
const AC_ARRAY_WRITE_SLOW: &[&str] = &["@write", "@array", "@slow"];
const READ_MOVABLE: &[&str] = &["readonly", "movablekeys"];
const WRITE_MOVABLE: &[&str] = &["write", "denyoom", "movablekeys"];
const MIGRATE_FLAGS: &[&str] = &["write", "movablekeys"];
const AC_CONN: &[&str] = &["@fast", "@connection"];
const AC_KEY_READ: &[&str] = &["@keyspace", "@read", "@fast"];
const AC_KEY_READ_SLOW: &[&str] = &["@keyspace", "@read", "@slow"];
const AC_KEY_READ_ALL: &[&str] = &["@keyspace", "@read", "@slow", "@dangerous"];
const AC_KEY_WRITE_SLOW: &[&str] = &["@keyspace", "@write", "@slow"];
const AC_KEY_WRITE_FAST: &[&str] = &["@keyspace", "@write", "@fast"];
const AC_KEY_FLUSH: &[&str] = &["@keyspace", "@write", "@slow", "@dangerous"];
const AC_SWAPDB: &[&str] = &["@keyspace", "@write", "@fast", "@dangerous"];
const AC_RESTORE: &[&str] = &["@keyspace", "@write", "@slow", "@dangerous"];
const AC_WAIT: &[&str] = &["@slow", "@blocking", "@connection"];
const AC_SORT_WRITE: &[&str] = &[
"@write",
"@set",
"@sortedset",
"@list",
"@slow",
"@dangerous",
];
const AC_SORT_READ: &[&str] = &[
"@read",
"@set",
"@sortedset",
"@list",
"@slow",
"@dangerous",
];
pub static COMMANDS: &[Spec] = &[
Spec {
name: "set",
arity: -3,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_SLOW,
since: "1.0.0",
complexity: "O(1)",
summary: "Set a key to a string value, whatever it held before.",
group: "string",
},
Spec {
name: "get",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_READ_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "The string value of a key.",
group: "string",
},
Spec {
name: "getset",
arity: 3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Set a key and hand back what it held.",
group: "string",
},
Spec {
name: "getdel",
arity: 2,
flags: &["write", "fast"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "6.2.0",
complexity: "O(1)",
summary: "Read a key and delete it in the same step.",
group: "string",
},
Spec {
name: "getex",
arity: -2,
flags: &["write", "fast"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "6.2.0",
complexity: "O(1)",
summary: "Read a key and change its deadline in the same step.",
group: "string",
},
Spec {
name: "setnx",
arity: 3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Set a key only if it is not there.",
group: "string",
},
Spec {
name: "setex",
arity: 4,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_SLOW,
since: "2.0.0",
complexity: "O(1)",
summary: "Set a key and give it a deadline in seconds.",
group: "string",
},
Spec {
name: "psetex",
arity: 4,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_SLOW,
since: "2.6.0",
complexity: "O(1)",
summary: "Set a key and give it a deadline in milliseconds.",
group: "string",
},
Spec {
name: "mset",
arity: -3,
flags: WRITE_OOM,
first_key: 1,
last_key: -1,
step: 2,
acl: AC_WRITE_SLOW,
since: "1.0.1",
complexity: "O(N) with N the number of keys",
summary: "Set several keys, all of them or none.",
group: "string",
},
Spec {
name: "msetnx",
arity: -3,
flags: WRITE_OOM,
first_key: 1,
last_key: -1,
step: 2,
acl: AC_WRITE_SLOW,
since: "1.0.1",
complexity: "O(N) with N the number of keys",
summary: "Set several keys only if none of them are there.",
group: "string",
},
Spec {
name: "mget",
arity: -2,
flags: READ_FAST,
first_key: 1,
last_key: -1,
step: 1,
acl: AC_READ_FAST,
since: "1.0.0",
complexity: "O(N) with N the number of keys",
summary: "The values of several keys, in the order asked for.",
group: "string",
},
Spec {
name: "append",
arity: 3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "2.0.0",
complexity: "O(M) with M the length of the value being appended",
summary: "Add to the end of a string, creating it if it is not there.",
group: "string",
},
Spec {
name: "strlen",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_READ_FAST,
since: "2.2.0",
complexity: "O(1)",
summary: "How long a string value is, without reading it.",
group: "string",
},
Spec {
name: "setrange",
arity: 4,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_SLOW,
since: "2.2.0",
complexity: "O(M) with M the length of the replacement",
summary: "Overwrite part of a string at an offset, zero filling the gap.",
group: "string",
},
Spec {
name: "getrange",
arity: 4,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_READ_SLOW,
since: "2.4.0",
complexity: "O(N) with N the length of the answer",
summary: "Part of a string, by an inclusive range that may count backwards.",
group: "string",
},
Spec {
name: "substr",
arity: 4,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_READ_SLOW,
since: "1.0.0",
complexity: "O(N) with N the length of the answer",
summary: "GETRANGE under the name it had before 2.4.",
group: "string",
},
Spec {
name: "incr",
arity: 2,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Add one, starting from zero if the key is not there.",
group: "string",
},
Spec {
name: "decr",
arity: 2,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Take one away, starting from zero if the key is not there.",
group: "string",
},
Spec {
name: "incrby",
arity: 3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Add a number, starting from zero if the key is not there.",
group: "string",
},
Spec {
name: "decrby",
arity: 3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Take a number away, starting from zero if the key is not there.",
group: "string",
},
Spec {
name: "incrbyfloat",
arity: 3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "2.6.0",
complexity: "O(1)",
summary: "Add a float, starting from zero if the key is not there.",
group: "string",
},
Spec {
name: "lcs",
arity: -3,
flags: &["readonly"],
first_key: 1,
last_key: 2,
step: 1,
acl: AC_READ_SLOW,
since: "7.0.0",
complexity: "O(N*M) with N and M the lengths of the two values",
summary: "The longest subsequence two string values have in common.",
group: "string",
},
Spec {
name: "msetex",
arity: -4,
flags: &["write", "denyoom", "movablekeys"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_WRITE_SLOW,
since: "8.4.0",
complexity: "O(N) with N the number of keys",
summary: "Set several keys with one deadline and one condition over all of them.",
group: "string",
},
Spec {
name: "delex",
arity: -2,
flags: &["write", "fast"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "8.4.0",
complexity: "O(1) by value, O(N) by digest",
summary: "Delete a key only if it still holds what the caller thinks.",
group: "string",
},
Spec {
name: "digest",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_READ_FAST,
since: "8.4.0",
complexity: "O(N) with N the length of the value",
summary: "The XXH3 of a string value, as sixteen hex characters.",
group: "string",
},
Spec {
name: "increx",
arity: -2,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_WRITE_FAST,
since: "8.8.0",
complexity: "O(1)",
summary: "Count, with a bound, a saturation policy and a deadline.",
group: "string",
},
Spec {
name: "sadd",
arity: -3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_WRITE_FAST,
since: "1.0.0",
complexity: "O(N) with N the number of members being added",
summary: "Add members to a set, creating it if it is not there.",
group: "set",
},
Spec {
name: "srem",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_WRITE_FAST,
since: "1.0.0",
complexity: "O(N) with N the number of members being removed",
summary: "Take members out of a set, deleting the key if none are left.",
group: "set",
},
Spec {
name: "scard",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_READ_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "How many members a set has.",
group: "set",
},
Spec {
name: "sismember",
arity: 3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_READ_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Whether a member is in a set.",
group: "set",
},
Spec {
name: "smismember",
arity: -3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_READ_FAST,
since: "6.2.0",
complexity: "O(N) with N the number of members being asked about",
summary: "Whether each of several members is in a set, in the order asked.",
group: "set",
},
Spec {
name: "smembers",
arity: 2,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_READ_SLOW,
since: "1.0.0",
complexity: "O(N) with N the size of the set",
summary: "Every member of a set.",
group: "set",
},
Spec {
name: "spop",
arity: -2,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_WRITE_FAST,
since: "1.0.0",
complexity: "O(1) without a count, O(N) with one",
summary: "Take members out of a set at random and hand them back.",
group: "set",
},
Spec {
name: "srandmember",
arity: -2,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_READ_SLOW,
since: "1.0.0",
complexity: "O(1) without a count, O(N) with one",
summary: "Members of a set at random, leaving the set as it was.",
group: "set",
},
Spec {
name: "smove",
arity: 4,
flags: WRITE_FAST,
first_key: 1,
last_key: 2,
step: 1,
acl: AC_SET_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Move one member from one set to another.",
group: "set",
},
Spec {
name: "sscan",
arity: -3,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SET_READ_SLOW,
since: "2.8.0",
complexity: "O(1) a call, O(N) for a whole iteration",
summary: "Walk part of a set and say where to carry on from.",
group: "set",
},
Spec {
name: "sinter",
arity: -2,
flags: &["readonly"],
first_key: 1,
last_key: -1,
step: 1,
acl: AC_SET_READ_SLOW,
since: "1.0.0",
complexity: "O(N*M) worst case, N the smallest set and M the number of sets",
summary: "The members every one of these sets has.",
group: "set",
},
Spec {
name: "sintercard",
arity: -3,
flags: READ_MOVABLE,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_SET_READ_SLOW,
since: "7.0.0",
complexity: "O(N*M) worst case, N the smallest set and M the number of sets",
summary: "How many members every one of these sets has, up to a limit.",
group: "set",
},
Spec {
name: "sinterstore",
arity: -3,
flags: WRITE_OOM,
first_key: 1,
last_key: -1,
step: 1,
acl: AC_SET_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N*M) worst case, N the smallest set and M the number of sets",
summary: "Store the members every one of these sets has.",
group: "set",
},
Spec {
name: "sunion",
arity: -2,
flags: &["readonly"],
first_key: 1,
last_key: -1,
step: 1,
acl: AC_SET_READ_SLOW,
since: "1.0.0",
complexity: "O(N) in the total number of members",
summary: "The members any of these sets has, each once.",
group: "set",
},
Spec {
name: "sunionstore",
arity: -3,
flags: WRITE_OOM,
first_key: 1,
last_key: -1,
step: 1,
acl: AC_SET_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N) in the total number of members",
summary: "Store the members any of these sets has.",
group: "set",
},
Spec {
name: "sdiff",
arity: -2,
flags: &["readonly"],
first_key: 1,
last_key: -1,
step: 1,
acl: AC_SET_READ_SLOW,
since: "1.0.0",
complexity: "O(N) in the total number of members",
summary: "The members of the first set that no later set has.",
group: "set",
},
Spec {
name: "sdiffstore",
arity: -3,
flags: WRITE_OOM,
first_key: 1,
last_key: -1,
step: 1,
acl: AC_SET_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N) in the total number of members",
summary: "Store the members of the first set that no later set has.",
group: "set",
},
Spec {
name: "hset",
arity: -4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "2.0.0",
complexity: "O(N) with N the number of pairs being written",
summary: "Write fields into a hash, creating it if it is not there.",
group: "hash",
},
Spec {
name: "hsetnx",
arity: 4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "2.0.0",
complexity: "O(1)",
summary: "Write a field only if the hash does not have it already.",
group: "hash",
},
Spec {
name: "hmset",
arity: -4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "2.0.0",
complexity: "O(N) with N the number of pairs being written",
summary: "Write fields into a hash and answer OK. Use HSET.",
group: "hash",
},
Spec {
name: "hget",
arity: 3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "2.0.0",
complexity: "O(1)",
summary: "The value of one field of a hash.",
group: "hash",
},
Spec {
name: "hmget",
arity: -3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "2.0.0",
complexity: "O(N) with N the number of fields asked for",
summary: "The values of several fields, one reply entry each.",
group: "hash",
},
Spec {
name: "hdel",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "2.0.0",
complexity: "O(N) with N the number of fields being removed",
summary: "Take fields out of a hash, deleting the key if none are left.",
group: "hash",
},
Spec {
name: "hlen",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "2.0.0",
complexity: "O(1)",
summary: "How many fields a hash has.",
group: "hash",
},
Spec {
name: "hexists",
arity: 3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "2.0.0",
complexity: "O(1)",
summary: "Whether a hash has a field.",
group: "hash",
},
Spec {
name: "hstrlen",
arity: 3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "3.2.0",
complexity: "O(1)",
summary: "How many bytes a field's value is, without sending it.",
group: "hash",
},
Spec {
name: "hgetall",
arity: 2,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_SLOW,
since: "2.0.0",
complexity: "O(N) in the size of the hash",
summary: "Every field and value, as a map on RESP3.",
group: "hash",
},
Spec {
name: "hkeys",
arity: 2,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_SLOW,
since: "2.0.0",
complexity: "O(N) in the size of the hash",
summary: "Every field of a hash.",
group: "hash",
},
Spec {
name: "hvals",
arity: 2,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_SLOW,
since: "2.0.0",
complexity: "O(N) in the size of the hash",
summary: "Every value of a hash.",
group: "hash",
},
Spec {
name: "hincrby",
arity: 4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "2.0.0",
complexity: "O(1)",
summary: "Add an integer to a field, treating a missing one as zero.",
group: "hash",
},
Spec {
name: "hincrbyfloat",
arity: 4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "2.6.0",
complexity: "O(1)",
summary: "Add a float to a field, treating a missing one as zero.",
group: "hash",
},
Spec {
name: "hrandfield",
arity: -2,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_SLOW,
since: "6.2.0",
complexity: "O(1) without a count, O(N) with one",
summary: "Fields of a hash at random, leaving the hash as it was.",
group: "hash",
},
Spec {
name: "hscan",
arity: -3,
flags: &["readonly"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_SLOW,
since: "2.8.0",
complexity: "O(1) a call, O(N) for a whole iteration",
summary: "Walk part of a hash and say where to carry on from.",
group: "hash",
},
Spec {
name: "hexpire",
arity: -6,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "Put a deadline in seconds on hash fields.",
group: "hash",
},
Spec {
name: "hpexpire",
arity: -6,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "Put a deadline in milliseconds on hash fields.",
group: "hash",
},
Spec {
name: "hexpireat",
arity: -6,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "Put an absolute deadline in unix seconds on hash fields.",
group: "hash",
},
Spec {
name: "hpexpireat",
arity: -6,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "Put an absolute deadline in unix milliseconds on hash fields.",
group: "hash",
},
Spec {
name: "httl",
arity: -5,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "How long hash fields have left, in seconds.",
group: "hash",
},
Spec {
name: "hpttl",
arity: -5,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "How long hash fields have left, in milliseconds.",
group: "hash",
},
Spec {
name: "hexpiretime",
arity: -5,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "When hash fields fall due, in unix seconds.",
group: "hash",
},
Spec {
name: "hpexpiretime",
arity: -5,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_READ_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "When hash fields fall due, in unix milliseconds.",
group: "hash",
},
Spec {
name: "hpersist",
arity: -5,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "7.4.0",
complexity: "O(N) with N the number of fields named",
summary: "Take the deadlines off hash fields.",
group: "hash",
},
Spec {
name: "hgetdel",
arity: -5,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "8.0.0",
complexity: "O(N) with N the number of fields named",
summary: "Read hash fields and delete them.",
group: "hash",
},
Spec {
name: "hgetex",
arity: -5,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "8.0.0",
complexity: "O(N) with N the number of fields named",
summary: "Read hash fields and set their deadlines.",
group: "hash",
},
Spec {
name: "hsetex",
arity: -6,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_HASH_WRITE_FAST,
since: "8.0.0",
complexity: "O(N) with N the number of fields being set",
summary: "Set hash fields and their deadlines together.",
group: "hash",
},
Spec {
name: "lpush",
arity: -3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_FAST,
since: "1.0.0",
complexity: "O(N) with N the number of elements pushed",
summary: "Push elements onto the head of a list.",
group: "list",
},
Spec {
name: "rpush",
arity: -3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_FAST,
since: "1.0.0",
complexity: "O(N) with N the number of elements pushed",
summary: "Push elements onto the tail of a list.",
group: "list",
},
Spec {
name: "lpushx",
arity: -3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_FAST,
since: "2.2.0",
complexity: "O(N) with N the number of elements pushed",
summary: "Push elements onto the head of a list that already exists.",
group: "list",
},
Spec {
name: "rpushx",
arity: -3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_FAST,
since: "2.2.0",
complexity: "O(N) with N the number of elements pushed",
summary: "Push elements onto the tail of a list that already exists.",
group: "list",
},
Spec {
name: "lpop",
arity: -2,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_FAST,
since: "1.0.0",
complexity: "O(N) with N the count asked for",
summary: "Take elements off the head of a list.",
group: "list",
},
Spec {
name: "rpop",
arity: -2,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_FAST,
since: "1.0.0",
complexity: "O(N) with N the count asked for",
summary: "Take elements off the tail of a list.",
group: "list",
},
Spec {
name: "llen",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_READ_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "How many elements a list holds.",
group: "list",
},
Spec {
name: "lrange",
arity: 4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_READ_SLOW,
since: "1.0.0",
complexity: "O(S+N) with S the offset of the first element and N the range",
summary: "Read a range of a list, both ends included.",
group: "list",
},
Spec {
name: "lindex",
arity: 3,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_READ_SLOW,
since: "1.0.0",
complexity: "O(N) with N the distance to the index from the nearer end",
summary: "Read one element of a list by index.",
group: "list",
},
Spec {
name: "lset",
arity: 4,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N) with N the distance to the index from the nearer end",
summary: "Replace one element of a list by index.",
group: "list",
},
Spec {
name: "linsert",
arity: 5,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_SLOW,
since: "2.2.0",
complexity: "O(N) with N the distance to the pivot from the head",
summary: "Insert an element before or after another one.",
group: "list",
},
Spec {
name: "lrem",
arity: 4,
flags: WRITE_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N) with N the length of the list",
summary: "Remove elements equal to a value from a list.",
group: "list",
},
Spec {
name: "ltrim",
arity: 4,
flags: WRITE_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N) with N the number of elements thrown away",
summary: "Keep a range of a list and throw the rest away.",
group: "list",
},
Spec {
name: "lpos",
arity: -3,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_LIST_READ_SLOW,
since: "6.0.6",
complexity: "O(N) with N the length of the list",
summary: "Find where a value sits in a list.",
group: "list",
},
Spec {
name: "rpoplpush",
arity: 3,
flags: WRITE_OOM,
first_key: 1,
last_key: 2,
step: 1,
acl: AC_LIST_WRITE_SLOW,
since: "1.2.0",
complexity: "O(1)",
summary: "Move an element from the tail of one list to the head of another.",
group: "list",
},
Spec {
name: "lmove",
arity: 5,
flags: WRITE_OOM,
first_key: 1,
last_key: 2,
step: 1,
acl: AC_LIST_WRITE_SLOW,
since: "6.2.0",
complexity: "O(1)",
summary: "Move an element from either end of one list to either end of another.",
group: "list",
},
Spec {
name: "lmpop",
arity: -4,
flags: &["write", "movablekeys"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_LIST_WRITE_SLOW,
since: "7.0.0",
complexity: "O(N+M) with N the number of keys and M the count popped",
summary: "Pop from the first of several lists that has anything in it.",
group: "list",
},
Spec {
name: "blpop",
arity: -3,
flags: &["write", "blocking"],
first_key: 1,
last_key: -2,
step: 1,
acl: AC_LIST_WRITE_BLOCKING,
since: "2.0.0",
complexity: "O(N) with N the number of keys named",
summary: "Pop the head of the first list that has anything, waiting if none does.",
group: "list",
},
Spec {
name: "brpop",
arity: -3,
flags: &["write", "blocking"],
first_key: 1,
last_key: -2,
step: 1,
acl: AC_LIST_WRITE_BLOCKING,
since: "2.0.0",
complexity: "O(N) with N the number of keys named",
summary: "Pop the tail of the first list that has anything, waiting if none does.",
group: "list",
},
Spec {
name: "blmove",
arity: 6,
flags: &["write", "denyoom", "blocking"],
first_key: 1,
last_key: 2,
step: 1,
acl: AC_LIST_WRITE_BLOCKING,
since: "6.2.0",
complexity: "O(1)",
summary: "Move an element between two lists, waiting for one to arrive.",
group: "list",
},
Spec {
name: "brpoplpush",
arity: 4,
flags: &["write", "denyoom", "blocking"],
first_key: 1,
last_key: 2,
step: 1,
acl: AC_LIST_WRITE_BLOCKING,
since: "2.2.0",
complexity: "O(1)",
summary: "Move a tail element to another list's head, waiting for one to arrive.",
group: "list",
},
Spec {
name: "blmpop",
arity: -5,
flags: &["write", "blocking", "movablekeys"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_LIST_WRITE_BLOCKING,
since: "7.0.0",
complexity: "O(N+M) with N the number of keys and M the count popped",
summary: "Pop from the first of several lists that has anything, waiting if none does.",
group: "list",
},
Spec {
name: "zadd",
arity: -4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_FAST,
since: "1.2.0",
complexity: "O(log(N)) for each member added",
summary: "Add members with scores, or move the scores of members already there.",
group: "zset",
},
Spec {
name: "zincrby",
arity: 4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_FAST,
since: "1.2.0",
complexity: "O(log(N))",
summary: "Add to a member's score, creating the member at zero if it is not there.",
group: "zset",
},
Spec {
name: "zcard",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "1.2.0",
complexity: "O(1)",
summary: "How many members a sorted set has.",
group: "zset",
},
Spec {
name: "zscore",
arity: 3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "1.2.0",
complexity: "O(1)",
summary: "A member's score, or nothing if it is not there.",
group: "zset",
},
Spec {
name: "zmscore",
arity: -3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "6.2.0",
complexity: "O(N) with N the number of members asked about",
summary: "The scores of several members in one round trip.",
group: "zset",
},
Spec {
name: "zrem",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_FAST,
since: "1.2.0",
complexity: "O(M*log(N)) with M the number of members removed",
summary: "Remove members, deleting the key if the last one goes.",
group: "zset",
},
Spec {
name: "zrank",
arity: -3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "2.0.0",
complexity: "O(log(N))",
summary: "Where a member sits counting up from the lowest score.",
group: "zset",
},
Spec {
name: "zrevrank",
arity: -3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "2.0.0",
complexity: "O(log(N))",
summary: "Where a member sits counting down from the highest score.",
group: "zset",
},
Spec {
name: "zcount",
arity: 4,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "2.0.0",
complexity: "O(log(N))",
summary: "How many members have scores between two bounds.",
group: "zset",
},
Spec {
name: "zlexcount",
arity: 4,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_FAST,
since: "2.8.9",
complexity: "O(log(N))",
summary: "How many members fall between two members, by name.",
group: "zset",
},
Spec {
name: "zrange",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "1.2.0",
complexity: "O(log(N)+M) with M the number of members answered",
summary: "A window of members, by rank or by score or by name, either way round.",
group: "zset",
},
Spec {
name: "zrevrange",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "1.2.0",
complexity: "O(log(N)+M) with M the number of members answered",
summary: "A window by rank, counting down from the highest score.",
group: "zset",
},
Spec {
name: "zrangebyscore",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "1.0.5",
complexity: "O(log(N)+M) with M the number of members answered",
summary: "The members whose scores fall between two bounds.",
group: "zset",
},
Spec {
name: "zrevrangebyscore",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "2.2.0",
complexity: "O(log(N)+M) with M the number of members answered",
summary: "The same window as ZRANGEBYSCORE, highest score first and named high end first.",
group: "zset",
},
Spec {
name: "zrangebylex",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "2.8.9",
complexity: "O(log(N)+M) with M the number of members answered",
summary: "The members that fall between two names, for a set where every score is the same.",
group: "zset",
},
Spec {
name: "zrevrangebylex",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "2.8.9",
complexity: "O(log(N)+M) with M the number of members answered",
summary: "The same window as ZRANGEBYLEX, backwards and named high end first.",
group: "zset",
},
Spec {
name: "zrangestore",
arity: -5,
flags: WRITE_OOM,
first_key: 1,
last_key: 2,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "6.2.0",
complexity: "O(log(N)+M) with M the number of members stored",
summary: "Write a window of one sorted set into another key.",
group: "zset",
},
Spec {
name: "zremrangebyrank",
arity: 4,
flags: WRITE_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "2.0.0",
complexity: "O(log(N)+M) with M the number of members removed",
summary: "Remove the members in a range of ranks.",
group: "zset",
},
Spec {
name: "zremrangebyscore",
arity: 4,
flags: WRITE_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "1.2.0",
complexity: "O(log(N)+M) with M the number of members removed",
summary: "Remove the members whose scores fall between two bounds.",
group: "zset",
},
Spec {
name: "zremrangebylex",
arity: 4,
flags: WRITE_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "2.8.9",
complexity: "O(log(N)+M) with M the number of members removed",
summary: "Remove the members that fall between two names.",
group: "zset",
},
Spec {
name: "zunion",
arity: -3,
flags: READ_MOVABLE,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_ZSET_READ_SLOW,
since: "6.2.0",
complexity: "O(N)+O(M*log(M)) with N the total number of members and M the number in the answer",
summary: "Every member of these sorted sets, with the scores combined.",
group: "zset",
},
Spec {
name: "zinter",
arity: -3,
flags: READ_MOVABLE,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_ZSET_READ_SLOW,
since: "6.2.0",
complexity: "O(N)+O(M*log(M)) with N the total number of members and M the number in the answer",
summary: "Only the members all of these sorted sets have, with the scores combined.",
group: "zset",
},
Spec {
name: "zdiff",
arity: -3,
flags: READ_MOVABLE,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_ZSET_READ_SLOW,
since: "6.2.0",
complexity: "O(N)+O(M*log(M)) with N the total number of members and M the number in the answer",
summary: "The members of the first that none of the rest have.",
group: "zset",
},
Spec {
name: "zunionstore",
arity: -4,
flags: WRITE_MOVABLE,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "2.0.0",
complexity: "O(N)+O(M*log(M)) with N the total number of members and M the number in the answer",
summary: "Store the union in another key and say how big it is.",
group: "zset",
},
Spec {
name: "zinterstore",
arity: -4,
flags: WRITE_MOVABLE,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "2.0.0",
complexity: "O(N)+O(M*log(M)) with N the total number of members and M the number in the answer",
summary: "Store the intersection in another key and say how big it is.",
group: "zset",
},
Spec {
name: "zdiffstore",
arity: -4,
flags: WRITE_MOVABLE,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_SLOW,
since: "6.2.0",
complexity: "O(N)+O(M*log(M)) with N the total number of members and M the number in the answer",
summary: "Store the difference in another key and say how big it is.",
group: "zset",
},
Spec {
name: "zintercard",
arity: -3,
flags: READ_MOVABLE,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_ZSET_READ_SLOW,
since: "7.0.0",
complexity: "O(N*M) worst case, N the smallest input and M the number of inputs",
summary: "How many members the intersection would have, without building it.",
group: "zset",
},
Spec {
name: "zrandmember",
arity: -2,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "6.2.0",
complexity: "O(N) with N the number of members drawn",
summary: "Draw members at random, with or without replacement.",
group: "zset",
},
Spec {
name: "zscan",
arity: -3,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_READ_SLOW,
since: "2.8.0",
complexity: "O(1) per call, O(N) over a full walk",
summary: "Walk the members and their scores a batch at a time.",
group: "zset",
},
Spec {
name: "zpopmin",
arity: -2,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_FAST,
since: "5.0.0",
complexity: "O(log(N)*M) with M the number of members popped",
summary: "Take the lowest scoring members off and answer them.",
group: "zset",
},
Spec {
name: "zpopmax",
arity: -2,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ZSET_WRITE_FAST,
since: "5.0.0",
complexity: "O(log(N)*M) with M the number of members popped",
summary: "Take the highest scoring members off and answer them.",
group: "zset",
},
Spec {
name: "zmpop",
arity: -4,
flags: &["write", "movablekeys"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_ZSET_WRITE_SLOW,
since: "7.0.0",
complexity: "O(K) + O(M*log(N)) with K the keys named and M the count popped",
summary: "Pop from the first of several sorted sets that has anything in it.",
group: "zset",
},
Spec {
name: "bzpopmin",
arity: -3,
flags: &["write", "blocking", "fast"],
first_key: 1,
last_key: -2,
step: 1,
acl: AC_ZSET_BLOCKING_FAST,
since: "5.0.0",
complexity: "O(log(N)) with N the size of the sorted set that answers",
summary: "Take the lowest scoring member off the first sorted set that has one, waiting if none does.",
group: "zset",
},
Spec {
name: "bzpopmax",
arity: -3,
flags: &["write", "blocking", "fast"],
first_key: 1,
last_key: -2,
step: 1,
acl: AC_ZSET_BLOCKING_FAST,
since: "5.0.0",
complexity: "O(log(N)) with N the size of the sorted set that answers",
summary: "Take the highest scoring member off the first sorted set that has one, waiting if none does.",
group: "zset",
},
Spec {
name: "bzmpop",
arity: -5,
flags: &["write", "blocking", "movablekeys"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_ZSET_BLOCKING_SLOW,
since: "7.0.0",
complexity: "O(K) + O(M*log(N)) with K the keys named and M the count popped",
summary: "Pop from the first of several sorted sets that has anything, waiting if none does.",
group: "zset",
},
Spec {
name: "arset",
arity: -4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_FAST,
since: "8.8.0",
complexity: "O(N) with N the number of values",
summary: "Write values into consecutive positions from an index.",
group: "array",
},
Spec {
name: "armset",
arity: -4,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_FAST,
since: "8.8.0",
complexity: "O(N) with N the number of pairs",
summary: "Write index and value pairs, which need not be neighbours.",
group: "array",
},
Spec {
name: "arget",
arity: 3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_FAST,
since: "8.8.0",
complexity: "O(1)",
summary: "The value at one index, or a null if nothing is there.",
group: "array",
},
Spec {
name: "armget",
arity: -3,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_FAST,
since: "8.8.0",
complexity: "O(N) with N the number of indices",
summary: "The values at the indices named, in the order named.",
group: "array",
},
Spec {
name: "argetrange",
arity: 4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_SLOW,
since: "8.8.0",
complexity: "O(N) with N the length of the range",
summary: "One reply per position between two indices, holes included.",
group: "array",
},
Spec {
name: "arlen",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_FAST,
since: "8.8.0",
complexity: "O(1)",
summary: "The highest populated index plus one.",
group: "array",
},
Spec {
name: "arcount",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_FAST,
since: "8.8.0",
complexity: "O(1)",
summary: "How many indices hold something.",
group: "array",
},
Spec {
name: "ardel",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_FAST,
since: "8.8.0",
complexity: "O(N) with N the number of indices",
summary: "Empty the indices named and say how many held something.",
group: "array",
},
Spec {
name: "ardelrange",
arity: -4,
flags: WRITE_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_SLOW,
since: "8.8.0",
complexity: "O(N) with N the elements touched, not the span asked for",
summary: "Empty one or more ranges of indices.",
group: "array",
},
Spec {
name: "arinsert",
arity: -3,
flags: WRITE_FAST_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_FAST,
since: "8.8.0",
complexity: "O(N) with N the number of values",
summary: "Append values at the insert cursor.",
group: "array",
},
Spec {
name: "arring",
arity: -4,
flags: WRITE_OOM,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_SLOW,
since: "8.8.0",
complexity: "O(N) with N the values, plus the ring size when it changes",
summary: "Append values into a ring of the given size.",
group: "array",
},
Spec {
name: "arnext",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_FAST,
since: "8.8.0",
complexity: "O(1)",
summary: "The index the next append would write to.",
group: "array",
},
Spec {
name: "arseek",
arity: 3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_WRITE_FAST,
since: "8.8.0",
complexity: "O(1)",
summary: "Point the insert cursor at an index.",
group: "array",
},
Spec {
name: "arlastitems",
arity: -3,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_SLOW,
since: "8.8.0",
complexity: "O(N) with N the count asked for",
summary: "The newest positions from the insert cursor, holes included.",
group: "array",
},
Spec {
name: "arscan",
arity: -4,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_SLOW,
since: "8.8.0",
complexity: "O(N) with N the elements found, not the span asked for",
summary: "Index and value pairs for what a range holds, skipping holes.",
group: "array",
},
Spec {
name: "argrep",
arity: -6,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_SLOW,
since: "8.8.0",
complexity: "O(P * C) with P the positions visited and C the cost of the predicates on one element",
summary: "The indexes in a range whose elements answer a set of textual predicates.",
group: "array",
},
Spec {
name: "arop",
arity: -5,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_SLOW,
since: "8.8.0",
complexity: "O(N) with N the elements found, not the span asked for",
summary: "One number out of a range, added up or compared or counted.",
group: "array",
},
Spec {
name: "arinfo",
arity: -2,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_ARRAY_READ_SLOW,
since: "8.8.0",
complexity: "O(1), or O(N) with N the slices when FULL is given",
summary: "The shape of the array, and what its slices look like.",
group: "array",
},
Spec {
name: "del",
arity: -2,
flags: &["write"],
first_key: 1,
last_key: -1,
step: 1,
acl: AC_KEY_WRITE_SLOW,
since: "1.0.0",
complexity: "O(N) in the number of keys.",
summary: "Delete keys and say how many were there.",
group: "keyspace",
},
Spec {
name: "unlink",
arity: -2,
flags: &["write", "fast"],
first_key: 1,
last_key: -1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "4.0.0",
complexity: "O(1) per key, since the freeing is not on this thread.",
summary: "Delete keys and free them out of the way of the reply.",
group: "keyspace",
},
Spec {
name: "exists",
arity: -2,
flags: READ_FAST,
first_key: 1,
last_key: -1,
step: 1,
acl: AC_KEY_READ,
since: "1.0.0",
complexity: "O(N) in the number of keys.",
summary: "Count how many of these keys are there, naming one twice counting twice.",
group: "keyspace",
},
Spec {
name: "type",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_READ,
since: "1.0.0",
complexity: "O(1)",
summary: "What kind of value is under a key, or none.",
group: "keyspace",
},
Spec {
name: "touch",
arity: -2,
flags: READ_FAST,
first_key: 1,
last_key: -1,
step: 1,
acl: AC_KEY_READ,
since: "3.2.1",
complexity: "O(N) in the number of keys.",
summary: "Count how many of these keys are there, and move them up the eviction order.",
group: "keyspace",
},
Spec {
name: "scan",
arity: -2,
flags: &["readonly"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_KEY_READ_SLOW,
since: "2.8.0",
complexity: "O(1) a call, O(N) for a whole iteration",
summary: "Walk part of the keyspace and say where to carry on from.",
group: "keyspace",
},
Spec {
name: "keys",
arity: 2,
flags: &["readonly"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_KEY_READ_ALL,
since: "1.0.0",
complexity: "O(N) in the number of keys.",
summary: "Every key matching a pattern, in one reply.",
group: "keyspace",
},
Spec {
name: "randomkey",
arity: 1,
flags: &["readonly"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_KEY_READ_SLOW,
since: "1.0.0",
complexity: "O(1)",
summary: "One key from the database, chosen at random.",
group: "keyspace",
},
Spec {
name: "rename",
arity: 3,
flags: &["write"],
first_key: 1,
last_key: 2,
step: 1,
acl: AC_KEY_WRITE_SLOW,
since: "1.0.0",
complexity: "O(1)",
summary: "Move a key to another name, over whatever was there.",
group: "keyspace",
},
Spec {
name: "renamenx",
arity: 3,
flags: WRITE_FAST,
first_key: 1,
last_key: 2,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Move a key to another name, but only if that name is free.",
group: "keyspace",
},
Spec {
name: "copy",
arity: -3,
flags: &["write", "denyoom"],
first_key: 1,
last_key: 2,
step: 1,
acl: AC_KEY_WRITE_SLOW,
since: "6.2.0",
complexity: "O(N) in the size of the value.",
summary: "Copy a value to another key, in this database or another one.",
group: "keyspace",
},
Spec {
name: "move",
arity: 3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Move a key to another database, if it is not already there.",
group: "keyspace",
},
Spec {
name: "wait",
arity: 3,
flags: &["blocking"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_WAIT,
since: "3.0.0",
complexity: "O(1)",
summary: "Wait for this connection's writes to reach a number of replicas.",
group: "keyspace",
},
Spec {
name: "waitaof",
arity: 4,
flags: &["blocking"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_WAIT,
since: "7.2.0",
complexity: "O(1)",
summary: "Wait for this connection's writes to reach the append only files.",
group: "keyspace",
},
Spec {
name: "dump",
arity: 2,
flags: READ_SLOW,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_READ_SLOW,
since: "2.6.0",
complexity: "O(1) to find the key, then O(N) in the size of the value.",
summary: "Serialize a value into a payload another server can load.",
group: "keyspace",
},
Spec {
name: "restore",
arity: -4,
flags: &["write", "denyoom"],
first_key: 1,
last_key: 1,
step: 1,
acl: AC_RESTORE,
since: "2.6.0",
complexity: "O(1) to find the key, then O(N) in the size of the payload.",
summary: "Create a key from a payload produced by DUMP.",
group: "keyspace",
},
Spec {
name: "migrate",
arity: -6,
flags: MIGRATE_FLAGS,
first_key: 3,
last_key: 3,
step: 1,
acl: AC_RESTORE,
since: "2.6.0",
complexity: "A DUMP and a DEL here, a RESTORE there, and the bytes in between.",
summary: "Move a key to another server.",
group: "keyspace",
},
Spec {
name: "sort",
arity: -2,
flags: WRITE_MOVABLE,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SORT_WRITE,
since: "1.0.0",
complexity: "O(N+M*log(M)) with N elements and M returned.",
summary: "Sort a list, set or sorted set, optionally into another key.",
group: "keyspace",
},
Spec {
name: "sort_ro",
arity: -2,
flags: READ_MOVABLE,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_SORT_READ,
since: "7.0.0",
complexity: "O(N+M*log(M)) with N elements and M returned.",
summary: "Sort a list, set or sorted set, without the STORE option.",
group: "keyspace",
},
Spec {
name: "expire",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "1.0.0",
complexity: "O(1)",
summary: "Put a deadline on a key, counted in seconds from now.",
group: "keyspace",
},
Spec {
name: "pexpire",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "2.6.0",
complexity: "O(1)",
summary: "Put a deadline on a key, counted in milliseconds from now.",
group: "keyspace",
},
Spec {
name: "expireat",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "1.2.0",
complexity: "O(1)",
summary: "Put a deadline on a key, as a unix time in seconds.",
group: "keyspace",
},
Spec {
name: "pexpireat",
arity: -3,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "2.6.0",
complexity: "O(1)",
summary: "Put a deadline on a key, as a unix time in milliseconds.",
group: "keyspace",
},
Spec {
name: "persist",
arity: 2,
flags: WRITE_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_WRITE_FAST,
since: "2.2.0",
complexity: "O(1)",
summary: "Take a key's deadline off, so it stops being temporary.",
group: "keyspace",
},
Spec {
name: "ttl",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_READ,
since: "1.0.0",
complexity: "O(1)",
summary: "How many seconds a key has left, -1 with no deadline, -2 if gone.",
group: "keyspace",
},
Spec {
name: "pttl",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_READ,
since: "2.6.0",
complexity: "O(1)",
summary: "How many milliseconds a key has left, -1 with no deadline, -2 if gone.",
group: "keyspace",
},
Spec {
name: "expiretime",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_READ,
since: "7.0.0",
complexity: "O(1)",
summary: "When a key falls due, as a unix time in seconds.",
group: "keyspace",
},
Spec {
name: "pexpiretime",
arity: 2,
flags: READ_FAST,
first_key: 1,
last_key: 1,
step: 1,
acl: AC_KEY_READ,
since: "7.0.0",
complexity: "O(1)",
summary: "When a key falls due, as a unix time in milliseconds.",
group: "keyspace",
},
Spec {
name: "object",
arity: -2,
flags: &[],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@slow"],
since: "2.2.3",
complexity: "O(1)",
summary: "Look at the machinery under a key rather than at its value.",
group: "keyspace",
},
Spec {
name: "script",
arity: -2,
flags: &[],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@slow"],
since: "2.6.0",
complexity: "O(1) for the subcommands that are here.",
summary: "The script cache, which is empty and stays empty until M6.",
group: "scripting",
},
Spec {
name: "function",
arity: -2,
flags: &[],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@slow"],
since: "7.0.0",
complexity: "O(1) for the subcommands that are here.",
summary: "The function libraries, of which there are none until M6.",
group: "scripting",
},
Spec {
name: "ping",
arity: -1,
flags: &["fast"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_CONN,
since: "1.0.0",
complexity: "O(1)",
summary: "Ask whether the server is answering.",
group: "connection",
},
Spec {
name: "echo",
arity: 2,
flags: &["loading", "stale", "fast"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_CONN,
since: "1.0.0",
complexity: "O(1)",
summary: "Send a string back unchanged.",
group: "connection",
},
Spec {
name: "hello",
arity: -1,
flags: &[
"noscript",
"loading",
"stale",
"fast",
"no_auth",
"allow_busy",
],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_CONN,
since: "6.0.0",
complexity: "O(1)",
summary: "Agree on a protocol version and describe the server.",
group: "connection",
},
Spec {
name: "select",
arity: 2,
flags: &["loading", "stale", "fast"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_CONN,
since: "1.0.0",
complexity: "O(1)",
summary: "Choose which database this connection works in.",
group: "connection",
},
Spec {
name: "reset",
arity: 1,
flags: &[
"noscript",
"loading",
"stale",
"fast",
"no_auth",
"allow_busy",
],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_CONN,
since: "6.2.0",
complexity: "O(1)",
summary: "Put the connection back the way it was opened.",
group: "connection",
},
Spec {
name: "quit",
arity: -1,
flags: &[
"noscript",
"loading",
"stale",
"fast",
"no_auth",
"allow_busy",
],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_CONN,
since: "1.0.0",
complexity: "O(1)",
summary: "Close the connection after the replies already queued.",
group: "connection",
},
Spec {
name: "command",
arity: -1,
flags: &["loading", "stale"],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@slow", "@connection"],
since: "2.8.13",
complexity: "O(N) with N the number of commands",
summary: "What this server can do, in the shape client libraries read.",
group: "server",
},
Spec {
name: "config",
arity: -2,
flags: &[],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@slow"],
since: "2.0.0",
complexity: "Depends on the subcommand.",
summary: "Read and change the settings a running server exposes.",
group: "server",
},
Spec {
name: "info",
arity: -1,
flags: &["loading", "stale"],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@slow", "@dangerous"],
since: "1.0.0",
complexity: "O(1)",
summary: "The server's own numbers, in sections.",
group: "server",
},
Spec {
name: "dbsize",
arity: 1,
flags: READ_FAST,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_KEY_READ,
since: "1.0.0",
complexity: "O(1)",
summary: "How many keys are in the database this connection is on.",
group: "server",
},
Spec {
name: "flushall",
arity: -1,
flags: &["write"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_KEY_FLUSH,
since: "1.0.0",
complexity: "O(N) in the number of keys in every database.",
summary: "Empty every database.",
group: "server",
},
Spec {
name: "flushdb",
arity: -1,
flags: &["write"],
first_key: 0,
last_key: 0,
step: 0,
acl: AC_KEY_FLUSH,
since: "1.0.0",
complexity: "O(N) in the number of keys in this database.",
summary: "Empty the database this connection is on.",
group: "server",
},
Spec {
name: "swapdb",
arity: 3,
flags: WRITE_FAST,
first_key: 0,
last_key: 0,
step: 0,
acl: AC_SWAPDB,
since: "4.0.0",
complexity: "O(N) in the number of clients watching or blocked on either.",
summary: "Swap two databases, so every client on one sees the other.",
group: "server",
},
Spec {
name: "time",
arity: 1,
flags: &["loading", "stale", "fast"],
first_key: 0,
last_key: 0,
step: 0,
acl: &["@fast"],
since: "2.6.0",
complexity: "O(1)",
summary: "The server's clock, as seconds and microseconds.",
group: "server",
},
];
#[must_use]
pub fn lookup(name: &[u8]) -> Option<&'static Spec> {
COMMANDS
.iter()
.find(|c| c.name.len() == name.len() && c.name.as_bytes().eq_ignore_ascii_case(name))
}
#[must_use]
pub fn arity_ok(spec: &Spec, n: usize) -> bool {
let n = n as i32;
if spec.arity >= 0 {
n == spec.arity
} else {
n >= -spec.arity
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_name_is_lower_case_and_appears_once() {
let mut seen = std::collections::BTreeSet::new();
for c in COMMANDS {
assert_eq!(
c.name,
c.name.to_lowercase(),
"{} is not lower case",
c.name
);
assert!(seen.insert(c.name), "{} is in the table twice", c.name);
}
}
#[test]
fn lookup_ignores_case_and_does_not_match_a_prefix() {
assert_eq!(lookup(b"GET").unwrap().name, "get");
assert_eq!(lookup(b"gEt").unwrap().name, "get");
assert!(lookup(b"ge").is_none());
assert!(lookup(b"gets").is_none());
}
#[test]
fn arity_counts_the_command_name() {
let get = lookup(b"get").unwrap();
assert!(!arity_ok(get, 1));
assert!(arity_ok(get, 2));
assert!(!arity_ok(get, 3));
let set = lookup(b"set").unwrap();
assert!(!arity_ok(set, 2));
assert!(arity_ok(set, 3));
assert!(arity_ok(set, 9));
}
#[test]
fn the_pair_commands_step_two_keys_at_a_time() {
for name in [b"mset".as_slice(), b"msetnx"] {
let c = lookup(name).unwrap();
assert_eq!((c.first_key, c.last_key, c.step), (1, -1, 2));
}
let mget = lookup(b"mget").unwrap();
assert_eq!((mget.first_key, mget.last_key, mget.step), (1, -1, 1));
let msetex = lookup(b"msetex").unwrap();
assert_eq!((msetex.first_key, msetex.last_key, msetex.step), (0, 0, 0));
assert!(msetex.flags.contains(&"movablekeys"));
}
}