Redis键-值数据库 nosql 数据建模(5)------ 如何存储树形结构的数据

作者:QQ 14588019 WonderfulLife

关系型数据库电商产品分类表 catgories
id      name                   parentId       idPath 
101     level1 1st category    0              0-101
1001    level2 1st category    101            0-101-1001
1002    level2 2nd category    101            0-101-1002
1003    level2 3rd category    101            0-101-1003
1004    level2 4th category    101            0-101-1004
10001   level3 1st category    1001           0-101-1001-10001
10002   level3 2nd category    1001           0-101-1001-10002
10003   level3 3rd category    1001           0-101-1001-10003
10004   level3 4th category    1001           0-101-1001-10004
10005   level3 5th category    1001           0-101-1001-10005
10006   level3 6th category    1002           0-101-1002-10006
10007   level3 7th category    1002           0-101-1002-10007
10008   level3 8th category    1002           0-101-1002-10008
10009   level3 9th category    1002           0-101-1002-10009
10010   level3 10th category   1002           0-101-1002-10010
10011   level3 11th category   1002           0-101-1002-10011
10012   level3 12th category   1002           0-101-1002-10012
10013   level3 13th category   1002           0-101-1002-10013
10014   level3 14th category   1002           0-101-1002-10014
10015   level3 15th category   1002           0-101-1002-10015
10016   level3 16th category   1002           0-101-1002-10016
10017   level3 17th category   1002           0-101-1002-10017
10018   level3 18th category   1003           0-101-1003-10018
10019   level3 19th category   1003           0-101-1003-10019
10020   level3 20th category   1003           0-101-1003-10020
10021   level3 21st category   1003           0-101-1003-10021
10022   level3 22nd category   1003           0-101-1003-10022
10023   level3 23rd category   1003           0-101-1003-10023
10024   level3 24th category   1003           0-101-1003-10024
10025   level3 25th category   1003           0-101-1003-10025
10026   level3 26th category   1003           0-101-1003-10026
10027   level3 27th category   1003           0-101-1003-10027
10028   level3 28th category   1003           0-101-1003-10028
10029   level3 29th category   1003           0-101-1003-10029
10030   level3 30th category   1003           0-101-1003-10030
10031   level3 31st category   1003           0-101-1003-10031
10032   level3 32nd category   1003           0-101-1003-10032
10033   level3 33rd category   1003           0-101-1003-10033
10034   level3 34th category   1003           0-101-1003-10034
10035   level3 35th category   1003           0-101-1003-10035
10036   level3 36th category   1003           0-101-1003-10036
10037   level3 37th category   1003           0-101-1003-10037
10038   level3 38th category   1003           0-101-1003-10038
10039   level3 39th category   1004           0-101-1004-10039
10040   level3 40th category   1004           0-101-1004-10040
10041   level3 41st category   1004           0-101-1004-10041

id      name                   parentId       idPath 
102     level1 1st category    0              0-102
1101    level2 1st category    102            0-102-1101
1102    level2 2nd category    102            0-102-1102
1103    level2 3rd category    102            0-102-1103
1104    level2 4th category    102            0-102-1104
1105    level2 5th category    102            0-102-1105
11001   level3 1st category    1101           0-102-1101-11001
11002   level3 2nd category    1101           0-102-1101-11002
11003   level3 3rd category    1101           0-102-1101-11003
11004   level3 4th category    1101           0-102-1101-11004
11005   level3 5th category    1101           0-102-1101-11005
11006   level3 6th category    1101           0-102-1101-11006
11007   level3 7th category    1102           0-102-1102-11007
11008   level3 8th category    1102           0-102-1102-11008
11009   level3 9th category    1102           0-102-1102-11009
11010   level3 10th category   1102           0-102-1102-11010
11011   level3 11th category   1102           0-102-1102-11011
11012   level3 12th category   1102           0-102-1102-11012
11013   level3 13th category   1102           0-102-1102-11013
11014   level3 14th category   1102           0-102-1102-11014
11015   level3 15th category   1102           0-102-1102-11015
11016   level3 16th category   1103           0-102-1103-11016
11017   level3 17th category   1103           0-102-1103-11017
11018   level3 18th category   1103           0-102-1103-11018
11019   level3 19th category   1103           0-102-1103-11019
11020   level3 20th category   1103           0-102-1103-11020
11021   level3 21st category   1103           0-102-1103-11021
11022   level3 22nd category   1103           0-102-1103-11022
11023   level3 23rd category   1103           0-102-1103-11023
11024   level3 24th category   1103           0-102-1103-11024
11025   level3 25th category   1103           0-102-1103-11025
11026   level3 26th category   1103           0-102-1103-11026
11027   level3 27th category   1103           0-102-1103-11027
11028   level3 28th category   1103           0-102-1103-11028
11029   level3 29th category   1103           0-102-1103-11029
11030   level3 30th category   1103           0-102-1103-11030
11031   level3 31st category   1103           0-102-1103-11031
11032   level3 32nd category   1104           0-102-1104-11032
11033   level3 33rd category   1104           0-102-1104-11033
11034   level3 34th category   1104           0-102-1104-11034
11035   level3 35th category   1104           0-102-1104-11035
11036   level3 36th category   1104           0-102-1104-11036
11037   level3 37th category   1104           0-102-1104-11037
11038   level3 38th category   1104           0-102-1104-11038
11039   level3 39th category   1105           0-102-1105-11039
11040   level3 40th category   1105           0-102-1105-11040
11041   level3 41st category   1105           0-102-1105-11041

第1组第1层树形目录level1的编号的id初始值从101开始,  增量为1;第2组第1层树形目录level1的编号的id初始值从102开始,  增量为1
第1组第2层树形目录level2的编号的id初始值从1001开始, 增量为1;第2组第2层树形目录level2的编号的id初始值从1101开始, 增量为1
第1组第3层树形目录level3的编号的id初始值从10001开始,增量为1;第2组第3层树形目录level3的编号的id初始值从11001开始,增量为1

后面扩展大的分类层次依此类推,为了遵循按区间分配id的设想要求,如下初始化设置可以满足设想需求:
127.0.0.1:6379> SET category:seq:g1l1 101
127.0.0.1:6379> SET category:seq:g1l2 1000
127.0.0.1:6379> SET category:seq:g1l3 10000
127.0.0.1:6379> SET category:seq:g2l1 102
127.0.0.1:6379> SET category:seq:g2l2 1100
127.0.0.1:6379> SET category:seq:g2l3 11000
127.0.0.1:6379> GET category:seq:g1l1
127.0.0.1:6379> HMSET category:101 id 101 name "level1 1st category" parentId 0 idPath "0-101"
127.0.0.1:6379> SADD category:101:sets "0-101"

127.0.0.1:6379> HGET category:101 idPath
127.0.0.1:6379> INCR category:seq:g1l2
127.0.0.1:6379> GET category:seq:g1l2
127.0.0.1:6379> HMSET category:1001 id 1001 name "level2 1st category" parentId 101 idPath "0-101-1001"
127.0.0.1:6379> SADD category:101:sets "0-101-1001"

127.0.0.1:6379> HGET category:101 idPath
127.0.0.1:6379> INCR category:seq:g1l2
127.0.0.1:6379> GET category:seq:g1l2
127.0.0.1:6379> HMSET category:1002 id 1002 name "level2 2nd category" parentId 101 idPath "0-101-1002"
127.0.0.1:6379> SADD category:101:sets "0-101-1002"

127.0.0.1:6379> HGET category:101 idPath
127.0.0.1:6379> INCR category:seq:g1l2
127.0.0.1:6379> GET category:seq:g1l2
127.0.0.1:6379> HMSET category:1003 id 1003 name "level2 3rd category" parentId 101 idPath "0-101-1003"
127.0.0.1:6379> SADD category:101:sets "0-101-1003"

127.0.0.1:6379> HGET category:101 idPath
127.0.0.1:6379> INCR category:seq:g1l2
127.0.0.1:6379> GET category:seq:g1l2
127.0.0.1:6379> HMSET category:1004 id 1004 name "level2 4th category" parentId 101 idPath "0-101-1004"
127.0.0.1:6379> SADD category:101:sets "0-101-1004"

127.0.0.1:6379> HGET category:1001 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10001 id 10001 name "level3 1st category" parentId 1001 idPath "0-101-1001-10001"
127.0.0.1:6379> SADD category:101:sets "0-101-1001-10001"

127.0.0.1:6379> HGET category:1001 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10002 id 10002 name "level3 2nd category" parentId 1001 idPath "0-101-1001-10002"
127.0.0.1:6379> SADD category:101:sets "0-101-1001-10002"

127.0.0.1:6379> HGET category:1001 idPat
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10003 id 10003 name "level3 3rd category" parentId 1001 idPath "0-101-1001-10003"
127.0.0.1:6379> SADD category:101:sets "0-101-1001-10003"

127.0.0.1:6379> HGET category:1001 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10004 id 10004 name "level3 4th category" parentId 1001 idPath "0-101-1001-10004"
127.0.0.1:6379> SADD category:101:sets "0-101-1001-10004"

127.0.0.1:6379> HGET category:1001 idPath
127.0.0.1:6379> INCR category:seq:g1l
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10005 id 10005 name "level3 5th category" parentId 1001 idPath "0-101-1001-10005"
127.0.0.1:6379> SADD category:101:sets "0-101-1001-10005"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10006 id 10006 name "level3 6th category" parentId 1002 idPath "0-101-1002-10006"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10006"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10007 id 10007 name "level3 7th category" parentId 1002 idPath "0-101-1002-10007"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10007"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10008 id 10008 name "level3 8th category" parentId 1002 idPath "0-101-1002-10008"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10008"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l
127.0.0.1:6379> HMSET category:10009 id 10009 name "level3 9th category" parentId 1002 idPath "0-101-1002-10009"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10009"

127.0.0.1:6379> HGET category:1002 idPat
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10010 id 10010 name "level3 10th category" parentId 1002 idPath "0-101-1002-10010"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10010"
127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10011 id 10011 name "level3 11th category" parentId 1002 idPath "0-101-1002-10011"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10011"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10012 id 10012 name "level3 12th category" parentId 1002 idPath "0-101-1002-10012"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10012"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10013 id 10013 name "level3 13th category" parentId 1002 idPath "0-101-1002-10013"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10013"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10014 id 10014 name "level3 14th category" parentId 1002 idPath "0-101-1002-10014"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10014"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10015 id 10015 name "level3 15th category" parentId 1002 idPath "0-101-1002-10015"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10015"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10016 id 10016 name "level3 16th category" parentId 1002 idPath "0-101-1002-10016
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10016"

127.0.0.1:6379> HGET category:1002 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10017 id 10017 name "level3 17th category" parentId 1002 idPath "0-101-1002-10017"
127.0.0.1:6379> SADD category:101:sets "0-101-1002-10017"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10018 id 10018 name "level3 18th category" parentId 1003 idPath "0-101-1003-10018"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10018"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10019 id 10019 name "level3 19th category" parentId 1003 idPath "0-101-1003-10019"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10019"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10020 id 10020 name "level3 20th category" parentId 1003 idPath "0-101-1003-10020"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10020"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10021 id 10021 name "level3 21st category" parentId 1003 idPath "0-101-1003-10021"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10021"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10022 id 10022 name "level3 22nd category" parentId 1003 idPath "0-101-1003-10022"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10022"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10023 id 10023 name "level3 23rd category" parentId 1003 idPath "0-101-1003-10023"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10023"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10024 id 10024 name "level3 24th category" parentId 1003 idPath "0-101-1003-10024"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10024"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10025 id 10025 name "level3 25th category" parentId 1003 idPath "0-101-1003-10025"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10025"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10026 id 10026 name "level3 26th category" parentId 1003 idPath "0-101-1003-10026"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10026"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10027 id 10027 name "level3 27th category" parentId 1003 idPath "0-101-1003-10027"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10027"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10028 id 10028 name "level3 28th category" parentId 1003 idPath "0-101-1003-10028
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10028"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l
127.0.0.1:6379> HMSET category:10029 id 10029 name "level3 29th category" parentId 1003 idPath "0-101-1003-10029"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10029"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10030 id 10030 name "level3 30th category" parentId 1003 idPath "0-101-1003-10030"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10030"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10031 id 10031 name "level3 31st category" parentId 1003 idPath "0-101-1003-10031"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10031"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10032 id 10032 name "level3 32nd category" parentId 1003 idPath "0-101-1003-10032"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10032"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10033 id 10033 name "level3 33rd category" parentId 1003 idPath "0-101-1003-10033"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10033"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10034 id 10034 name "level3 34th category" parentId 1003 idPath "0-101-1003-10034"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10034"
127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10035 id 10035 name "level3 35th category" parentId 1003 idPath "0-101-1003-10035"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10035"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10036 id 10036 name "level3 36th category" parentId 1003 idPath "0-101-1003-10036"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10036"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10037 id 10037 name "level3 37th category" parentId 1003 idPath "0-101-1003-10037"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10037"

127.0.0.1:6379> HGET category:1003 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10038 id 10038 name "level3 38th category" parentId 1003 idPath "0-101-1003-10038"
127.0.0.1:6379> SADD category:101:sets "0-101-1003-10038"

127.0.0.1:6379> HGET category:1004 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10039 id 10039 name "level3 39th category" parentId 1004 idPath "0-101-1004-10039"
127.0.0.1:6379> SADD category:101:sets "0-101-1004-10039"

127.0.0.1:6379> HGET category:1004 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10040 id 10040 name "level3 40th category" parentId 1004 idPath "0-101-1004-10040"
127.0.0.1:6379> SADD category:101:sets "0-101-1004-10040"

127.0.0.1:6379> HGET category:1004 idPath
127.0.0.1:6379> INCR category:seq:g1l3
127.0.0.1:6379> GET category:seq:g1l3
127.0.0.1:6379> HMSET category:10041 id 10041 name "level3 41st category" parentId 1004 idPath "0-101-1004-10041"
127.0.0.1:6379> SADD category:101:sets "0-101-1004-10041"
至此第1组商品数据分类添加完毕,第2组商品数据分类添加暂且省略


测试:
[root@contoso ~]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> SSCAN category:101:sets 0 MATCH "0-101-1004-*"   // 查询分类商品子类0-101-1004的所有分类
1) "2"
2) 1) "0-101-1004-10039"
127.0.0.1:6379> SSCAN category:101:sets 0 MATCH 0-101-1004-* COUNT 46
1) "0"
2)1) "0-101-1004-10039"
2) "0-101-1004-10040"
3) "0-101-1004-10041"
127.0.0.1:6379> 
127.0.0.1:6379> SMEMBERS category:101:sets
1) "0-101-1002-10013"
2) "0-101-1002-10008"
3) "0-101-1003-10024"
4) "0-101-1001-10004"
5) "0-101-1002-10006"
6) "0-101-1002-10014"
7) "0-101-1003-10020"
8) "0-101-1003-10018"
9) "0-101-1003-10021"
10) "0-101-1003-10023"
11) "0-101-1003-10022"
12) "0-101-1002-10016"
13) "0-101-1002-10017"
14) "0-101-1003"
15) "0-101-1002-10012"
16) "0-101"
17) "0-101-1003-10034"
18) "0-101-1003-10025"
19) "0-101-1004-10040"
20) "0-101-1003-10026"
21) "0-101-1002-10010"
22) "0-101-1001-10003"
23) "0-101-1003-10031"
24) "0-101-1003-10019"
25) "0-101-1002"
26) "0-101-1001-10001"
27) "0-101-1003-10027"
28) "0-101-1002-10007"
29) "0-101-1003-10038"
30) "0-101-1003-10028"
31) "0-101-1003-10037"
32) "0-101-1003-10036"
33) "0-101-1004"
34) "0-101-1002-10015"
35) "0-101-1002-10009"
36) "0-101-1001"
37) "0-101-1001-10002"
38) "0-101-1002-10011"
39) "0-101-1001-10005"
40) "0-101-1003-10030"
41) "0-101-1003-10029"
42) "0-101-1004-10039"
43) "0-101-1004-10041"
44) "0-101-1003-10032"
45) "0-101-1003-10035"
46) "0-101-1003-10033
127.0.0.1:6379> 
127.0.0.1:6379> SSCAN category:102:sets 0 MATCH "0-102-1104-*" COUNT 100
1) "0"
2) 1) "0-102-1104-11037"
   2) "0-102-1104-11032"
   3) "0-102-1104-11034"
   4) "0-102-1104-11033"
   5) "0-102-1104-11035"
   6) "0-102-1104-11036"
   7) "0-102-1104-11038"
127.0.0.1:6379> SSCAN category:102:sets 0 MATCH "0-102-*" COUNT 100
1) "0"
2)  1) "0-102-1104-11037"
    2) "0-102-1104-11032"
    3) "0-102-1103-11024"
    4) "0-102-1105-11040"
    5) "0-102-1103-11027"
    6) "0-102-1103-11020"
    7) "0-102-1102"
    8) "0-102-1105"
    9) "0-102-1102-11013"
    10) "0-102-1101-11006"
    11) "0-102-1103-11017"
    12) "0-102-1103-11023"
    13) "0-102-1104-11034"
    14) "0-102-1103-11031"
    15) "0-102-1102-11009"
    16) "0-102-1103-11018"
    17) "0-102-1101-11002"
    18) "0-102-1103-11028"
    19) "0-102-1102-11015"
    20) "0-102-1103-11029"
    21) "0-102-1102-11012"
    22) "0-102-1103-11026"
    23) "0-102-1104"
    24) "0-102-1104-11033"
    25) "0-102-1102-11007"
    26) "0-102-1103-11019"
    27) "0-102-1104-11035"
    28) "0-102-1103-11025"
    29) "0-102-1101-11003"
    30) "0-102-1105-11039"
    31) "0-102-1103-11030"
    32) "0-102-1101-11001"
    33) "0-102-1101-11005"
    34) "0-102-1102-11008"
    35) "0-102-1102-11011"
    36) "0-102-1104-11036"
    37) "0-102-1104-11038"
    38) "0-102-1103-11021"
    39) "0-102-1103-11016"
    40) "0-102-1101-11004"
    41) "0-102-1103"
    42) "0-102-1102-11010"
    43) "0-102-1103-11022"
    44) "0-102-1105-11041"
    45) "0-102-1001"
    46) "0-102-1102-11014"
127.0.0.1:6379> 
127.0.0.1:6379> SSCAN category:102:sets 0 MATCH "0-102-????" COUNT 100
1) "0"
2) 1) "0-102-1102"
   2) "0-102-1105"
   3) "0-102-1104"
   4) "0-102-1103"
   5) "0-102-1001"
127.0.0.1:6379> 
本篇讲解完毕 未经许可,不得商用出版发行!


猜你喜欢

转载自blog.csdn.net/zhengzizhi/article/details/80035125