Commands
Hint
This article is generated by AI translation.
- Update count: use
executeUpdate/getUpdateCountfor affected rows. - Result set: use
executeQuery/getResultSetto retrieve results.
Hash Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| HDEL | value | -- | Number of fields removed (0 if none or key missing) |
| HEXISTS | result set | 1 | RESULT (BOOLEAN) |
| HEXPIRE | result set | multiple | RESULT (LONG) |
| HEXPIREAT | result set | multiple | RESULT (LONG) |
| HEXPIRETIME | result set | multiple | RESULT (LONG) |
| HPEXPIRE | result set | multiple | RESULT (LONG) |
| HPEXPIREAT | result set | multiple | RESULT (LONG) |
| HPEXPIRETIME | result set | multiple | RESULT (LONG) |
| HGET | result set | 1 | VALUE (STRING) |
| HGETALL | result set | multiple | FIELD (STRING), VALUE (STRING) |
| HINCRBY | result set | 1 | VALUE (LONG) |
| HKEYS | result set | multiple | FIELD (STRING) |
| HLEN | result set | 1 | RESULT (LONG) |
| HMGET | result set | multiple | VALUE (STRING) |
| HSET | value | -- | Number of fields added |
| HMSET | value | -- | Number of fields added |
| HSETNX | value | -- | 0 if field exists; 1 if created |
| HPERSIST | result set | multiple | RESULT (LONG) |
| HTTL | result set | multiple | RESULT (LONG) |
| HPTTL | result set | multiple | RESULT (LONG) |
| HRANDFIELD | result set | multiple | FIELD (STRING); VALUE (STRING) when using WITHVALUES |
| HSCAN | result set | multiple | CURSOR (STRING); FIELD (STRING); VALUE (STRING) unless NOVALUES |
| HSTRLEN | result set | 1 | RESULT (LONG) |
| HVALS | result set | multiple | VALUE (STRING) |
Keys Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| COPY | value | -- | 1 if copied; 0 if failed |
| DEL | value | -- | >0 if removed; 0 if none existed |
| UNLINK | result set | 1 | RESULT (LONG) |
| DUMP | result set | 1 | VALUE (BYTES) |
| EXISTS | result set | 1 | RESULT (LONG) |
| EXPIRE | value | -- | 1 if timeout set; else 0 |
| EXPIREAT | value | -- | 1 if timeout set; else 0 |
| EXPIRETIME | result set | 1 | RESULT (LONG) |
| PEXPIRE | value | -- | 1 if timeout set; else 0 |
| PEXPIREAT | value | -- | 1 if timeout set; else 0 |
| PEXPIRETIME | result set | 1 | RESULT (LONG) |
| KEYS | result set | multiple | KEY (STRING) — driver uses SCAN internally |
| OBJECT ENCODING | result set | 1 | RESULT (STRING) |
| OBJECT FREQ | result set | 1 | RESULT (LONG) |
| OBJECT IDLETIME | result set | 1 | RESULT (LONG) |
| OBJECT REFCOUNT | result set | 1 | RESULT (LONG) |
| PERSIST | value | -- | 1 if key persisted; else 0 |
| TTL | result set | 1 | RESULT (LONG) |
| PTTL | result set | 1 | RESULT (LONG) |
| RANDOMKEY | result set | 1 | KEY (STRING) |
| RENAME | value | -- | 1 if renamed; 0 if target exists (check OK status) |
| RENAMENX | value | -- | 1 if renamed; 0 if target exists |
| SCAN | result set | multiple | CURSOR (STRING); KEY (STRING) |
| TOUCH | value | -- | Number of keys touched |
| TYPE | result set | 1 | RESULT (STRING) |
List Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| LMOVE | result set | 1 | ELEMENT (STRING) |
| BLMOVE | result set | 1 | ELEMENT (STRING) |
| LMPOP | result set | multiple | KEY (STRING); ELEMENT (STRING) |
| BLMPOP | result set | multiple | KEY (STRING); ELEMENT (STRING) |
| LPOP | result set | multiple | ELEMENT (STRING) |
| RPOP | result set | multiple | ELEMENT (STRING) |
| BLPOP | result set | multiple | ELEMENT (STRING) |
| BRPOP | result set | multiple | ELEMENT (STRING) |
| RPOPLPUSH | result set | 1 | ELEMENT (STRING) |
| BRPOPLPUSH | result set | 1 | ELEMENT (STRING) |
| LINDEX | result set | 1 | ELEMENT (STRING) |
| LINSERT | value | -- | Length after insert; 0 if key missing; -1 if pivot not found |
| LLEN | result set | 1 | RESULT (LONG) |
| LPOS | result set | multiple | RESULT (LONG) |
| LPUSH | value | -- | Length after push |
| LPUSHX | value | -- | Length after push |
| RPUSH | value | -- | Length after push |
| RPUSHX | value | -- | Length after push |
| LRANGE | result set | multiple | ELEMENT (STRING) |
| LREM | value | -- | Number of elements removed |
| LSET | value | -- | 1 if success; 0 otherwise (status OK means success) |
| LTRIM | value | -- | 1 if success; 0 otherwise (status OK means success) |
Server Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| MOVE | value | -- | 1 if moved; 0 if not |
| WAIT | result set | 1 | REPLICAS (LONG) |
| WAITAOF | result set | 1 | LOCAL (LONG); REPLICAS (LONG) |
| PING | result set | 1 | RESULT (STRING) |
| ECHO | result set | 1 | RESULT (STRING) |
| SELECT | value | -- | 1 on success; otherwise exception |
Set Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| SADD | value | -- | Elements added (excluding existing) |
| SCARD | result set | 1 | RESULT (LONG) |
| SDIFF | result set | multiple | ELEMENT (STRING) |
| SDIFFSTORE | value | -- | Elements in result set |
| SINTER | result set | multiple | ELEMENT (STRING) |
| SINTERCARD | result set | 1 | RESULT (LONG) |
| SINTERSTORE | value | -- | Elements in result set |
| SISMEMBER | result set | 1 | RESULT (LONG) |
| SMISMEMBER | result set | multiple | RESULT (BOOLEAN) |
| SMEMBERS | result set | multiple | ELEMENT (STRING) |
| SMOVE | value | -- | 1 if moved; 0 if not |
| SPOP | result set | multiple | ELEMENT (STRING) |
| SRANDMEMBER | result set | multiple | ELEMENT (STRING) |
| SREM | value | -- | Members removed (excluding non-existent) |
| SSCAN | result set | multiple | CURSOR (STRING); ELEMENT (STRING) |
| SUNION | result set | multiple | ELEMENT (STRING) |
| SUNIONSTORE | value | -- | Elements in result set |
StoreSet Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| ZMPOP | result set | multiple | KEY (STRING); ELEMENT (STRING); SCORE (DOUBLE) |
| BZMPOP | result set | multiple | KEY (STRING); ELEMENT (STRING); SCORE (DOUBLE) |
| ZPOPMAX | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE) |
| BZPOPMAX | result set | 1 | KEY (STRING); ELEMENT (STRING); SCORE (DOUBLE) |
| ZPOPMIN | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE) |
| BZPOPMIN | result set | 1 | KEY (STRING); ELEMENT (STRING); SCORE (DOUBLE) |
| ZADD | result set | 1 | RESULT (DOUBLE when INCR; LONG otherwise) |
| ZCARD | result set | 1 | RESULT (LONG) |
| ZCOUNT | result set | 1 | RESULT (LONG) |
| ZDIFF | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZDIFFSTORE | value | -- | Elements in result set |
| ZINCRBY | result set | 1 | SCORE (DOUBLE) |
| ZINTER | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZINTERCARD | result set | 1 | RESULT (LONG) |
| ZINTERSTORE | value | -- | Elements in result set |
| ZLEXCOUNT | result set | 1 | RESULT (LONG) |
| ZSCORE | result set | 1 | SCORE (DOUBLE) |
| ZMSCORE | result set | multiple | SCORE (DOUBLE) |
| ZRANDMEMBER | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZRANGE | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZRANGEBYLEX | result set | multiple | ELEMENT (STRING) |
| ZRANGEBYSCORE | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZRANGESTORE | value | -- | Elements in result set |
| ZRANK | result set | 1 | SCORE (DOUBLE with WITHSCORES); RANK (LONG) |
| ZREVRANK | result set | 1 | SCORE (DOUBLE with WITHSCORES); RANK (LONG) |
| ZREM | value | -- | Members removed (excluding non-existent) |
| ZREMRANGEBYLEX | value | -- | Members removed |
| ZREMRANGEBYRANK | value | -- | Members removed |
| ZREMRANGEBYSCORE | value | -- | Members removed |
| ZREVRANGE | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZREVRANGEBYLEX | result set | multiple | ELEMENT (STRING) |
| ZREVRANGEBYSCORE | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZSCAN | result set | multiple | CURSOR (STRING); ELEMENT (STRING); SCORE (DOUBLE) |
| ZUNION | result set | multiple | ELEMENT (STRING); SCORE (DOUBLE with WITHSCORES) |
| ZUNIONSTORE | value | -- | Elements in result set |
String Commands
| Command | Return | Rows | Result |
|---|---|---|---|
| SET | value/result set | --/1 | Value: 0 (not set) or 1 (set) when not using GET; Result set: VALUE (STRING) when using GET |
| GET | result set | 1 | VALUE (STRING) |
| INCR | result set | 1 | VALUE (LONG) |
| INCRBY | result set | 1 | VALUE (LONG) |
| DECR | result set | 1 | VALUE (LONG) |
| DECRBY | result set | 1 | VALUE (LONG) |
| APPEND | result set | 1 | RESULT (LONG) |
| GETDEL | result set | 1 | VALUE (STRING) |
| GETEX | result set | 1 | VALUE (STRING) |
| GETRANGE | result set | 1 | VALUE (STRING) |
| GETSET | result set | 1 | VALUE (STRING) |
| MGET | result set | multiple | KEY (STRING); VALUE (STRING) |
| MSET | value | -- | Number of keys added |
| MSETNX | value | -- | 0 if any key exists; otherwise number of keys set |
| PSETEX | value | -- | 1 if success; else 0 (status OK means success) |
| SETEX | value | -- | 1 if success; else 0 (status OK means success) |
| SETNX | value | -- | 1 if set; 0 otherwise |
| SETRANGE | value | -- | Length after modification |
| STRLEN | result set | 1 | RESULT (LONG) |
| SUBSTR | result set | 1 | VALUE (STRING) |