Redis - LLEN 命令



Redis LLEN 命令返回儲存在鍵中的列表的長度。如果鍵不存在,則將其解釋為空列表,並返回 0。當儲存在鍵中的值不是列表時,將返回一個錯誤。

返回值

整數回覆,鍵處的列表長度。

語法

以下是 Redis LLEN 命令的基本語法。

redis 127.0.0.1:6379> LLEN KEY_NAME

示例

redis 127.0.0.1:6379> RPUSH list1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> RPUSH list1 "bar" 
(integer) 2 
redis 127.0.0.1:6379> LLEN list1 
(integer) 2
redis_lists.htm
廣告
© . All rights reserved.