EXISTS

Syntax
EXISTS key [key ...]
Available since:
1.0.0
Time complexity:
O(N) where N is the number of keys to check.
ACL categories:
@keyspace, @read, @fast,

如果key存在则返回。

用户应该注意,如果在参数中多次提到相同的现有键,它将被多次计数。因此,如果somekey存在,EXISTS somekey somekey将返回2。

示例

SET key1 "Hello" EXISTS key1 EXISTS nosuchkey SET key2 "World" EXISTS key1 key2 nosuchkey

RESP2/RESP3 回复

Integer reply: the number of keys that exist from those specified as arguments.

历史

  • 从 Redis 版本 3.0.3 开始:接受多个 key 参数。
RATE THIS PAGE
Back to top ↑