redis> HSET myhash field1 "foo"(integer) 1
redis> HEXISTS myhash field1(integer) 1
redis> HEXISTS myhash field2(integer) 0
redis>
exists用來判斷key是否存在,只有1組參數時用法和hexists壹樣,時間復雜度也壹樣,所以效率沒區別。Redis3.0.3之後支持多組參數,返回存在的key的數量。
redis> SET key1 "Hello"OK
redis> EXISTS key1(integer) 1
redis> EXISTS nosuchkey(integer) 0
redis> SET key2 "World"OK
redis> EXISTS key1 key2 nosuchkey(integer) 2
redis>