First, sort
Sort <key> Sorting keys for a numeric value
1. Alpha sorts the keys of the string type
2, Asc/desc
Redis Default Ascending sort ASC
Desc is the opposite of
3. By
Sort by weight.
127.0.0.1:6379> Sadd usres"VIP" "Ordinary" "Visotor"(integer)3127.0.0.1:6379>Sort Usres Alpha1)"Ordinary"2)"VIP"3)"Visotor"127.0.0.1:6379> Mset Vip-sort1Ordinary-sort0Visotor-sort-1OK127.0.0.1:6379> Sort usres by * *Sort1)"Visotor"2)"Ordinary"3)"VIP"127.0.0.1:6379>
4, limit < from where to start >< marry a few >
127.0. 0.1:6379021"ordinary"2 "vip"127.0. 0.1:6379>
5. Get
Format after match with get pattern
127.0. 0.1:6379> sort usres alpha1"ordinary"2 " VIP " 3 " Visotor " 127.0. 0.1:6379>
127.0.0.1:6379>SetVip"SC"OK127.0.0.1:6379>SetOrdinary"KK"OK127.0.0.1:6379>SetVisotor"123EWDFRGV"OK127.0.0.1:6379> Sort Usres AlphaGet*1)"KK"2)"SC"3)"123EWDFRGV"127.0.0.1:6379>
6. Store sorting results
127.0.0.1:6379> Sort Usres AlphaGet*store names (integer)3127.0.0.1:6379> Lrange Names0-11)"KK"2)"SC"3)"123EWDFRGV"127.0.0.1:6379>
7. The above option execution order
A, sort: alpha, ASC, DESC, by
b, limiting the result set: Limit
C, get the foreign key: get
D. Save sort Result: Store
Second, slow query log
Set timeout milliseconds: Slowlog-slower-than
127.0. 0.1:6379set0
Ok
Set maximum number of records: Slowlog-max-len
127.0. 0.1:6379set3OK
View log: Slowlog get
127.0.0.1:6379>SetSc"Sun"OK127.0.0.1:6379>SetY"Yuan"OK127.0.0.1:6379>SetC"Ong"OK127.0.0.1:6379> SlowlogGet1)1) (integer)8//Log primary key 2) (integer)1520643052// timestamp 3) (integer)4// duration 4)1)"Set"//Command and Parameters 2)"C" 3)"Ong" 5)"127.0.0.1:34010" 6)""2)1) (integer)7 2) (integer)1520643032 3) (integer)3 4)1)"Set" 2)"y" 3)"Yuan" 5)"127.0.0.1:34010" 6)""3)1) (integer)6 2) (integer)1520643024 3) (integer)5 4)1)"Set" 2)"SC" 3)"Sun" 5)"127.0.0.1:34010" 6)""
Third, monitors monitor
Monitor client execution:
127.0. 0.1:6379> monitorok
To request the client, execute the command:
# redis-CLI127.0. 0.1:6379set"sc"OK127.0. 0.1:6379>
Monitor, monitor:
127.0.0.1:6379>Monitorok1520643372.474104[0 127.0.0.1:34012]"COMMAND"1520643389.095506[0 127.0.0.1:34012]"Set" "name" "SC"
Redis design and implementation (eight)-sort, slow query log, monitor