sort
SORT use zset
Redis 開発者教育の申込
|
Redis 定期点検/技術サポートRedis Technical Support |
Redis エンタープライズサーバーRedis Enterprise Server |
|---|
zset data を sort
Example
| コマンド> | zadd myzipurl 1 Google.com 2 Facebook.com 3 Youtube.com 4 Yahoo.com 5 Baidu.com |
| 結果> | 5 |
| コマンド> | sort myzipurl alpha member で sort |
| 結果> |
0) Baidu.com 1) Facebook.com 2) Google.com 3) Yahoo.com 4) Youtube.com |
| コマンド> | sort myzipurl by score alpha score で sort |
| 結果> |
0) Google.com 1) Facebook.com 2) Youtube.com 3) Yahoo.com 4) Baidu.com |
zset と by score, string key の join
zset で by を指定しないと member で sort され、by score を指定すると score で sort されます。
Example
| コマンド> | sort myzipurl by score get # get pv-* alpha |
| 結果> |
0) Google.com 1) 19.60 2) Facebook.com 3) 11.62 4) Youtube.com 5) 4.58 6) Yahoo.com 7) 7.44 8) Baidu.com 9) 8.87 |
zset と hash key の join
Example
| コマンド> | sort myzipurl by score get # get url-*->pv alpha |
| 結果> |
0) Google.com 1) 19.60 2) Facebook.com 3) 11.62 4) Youtube.com 5) 4.58 6) Yahoo.com 7) 7.44 8) Baidu.com 9) 8.87 |
構文
SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
- このコマンドは version 1.0.0 から使用できます。
- 時間計算量は O(N+M*log(M)) です。
| 関連コマンド | SCAN |
| << SORT list | SORT zset | RENAME >> |
|---|
Email
返事がかかってなれば、メールでお知らせします。
