Redis sorted set 使用: Redis 有序集合(sorted set) Redis 有序集合和集合一樣也是string類型元素的集合,且不允許重覆的成員。 不同的是每個元素都會關聯一個double類型的分數。redis正是通過分數來為集合中的成員進行從小到大的排序。 有序集合的成員是 ...
Redis sorted set 使用: Redis 有序集合(sorted set) Redis 有序集合和集合一樣也是string類型元素的集合,且不允許重覆的成員。 不同的是每個元素都會關聯一個double類型的分數。redis正是通過分數來為集合中的成員進行從小到大的排序。 有序集合的成員是唯一的,但分數(score)卻可以重覆。 集合是通過哈希表實現的,所以添加,刪除,查找的複雜度都是O(1)。 集合中最大的成員數為 232 - 1 (4294967295, 每個集合可存儲40多億個成員)。 添加: ZADD key score1 member1 [score2 member2]











