當前位置:編程學習大全網 - 行動軟體 - Redis命令exists和hexists有什麽區別嗎

Redis命令exists和hexists有什麽區別嗎

hexists只用來判斷是否存在參數所指定的hash字段,只可以帶壹個參數,返回值只有1(存在)和0(不存在)兩種情況。

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>

  • 上一篇:rar文件右鍵沒有解壓怎麽回事
  • 下一篇:新劇《他在逆光中告白》,掀起初戀“重生”風暴,妳對此怎麽看呢?
  • copyright 2024編程學習大全網