Commit c2c460f
committed
Set correct cluster slot for scan commands, similarly to Java's Jedis client
- At present, the `scan` command is dispatched to a random slot.
- As far as I can tell, the scanX family of commands are not cluster aware (e.g. don't redirect the client to the correct slot).
- You can see [here](https://github.com/redis/jedis/blob/869dc0bb6625b85c8bf15bf1361bde485a304338/src/main/java/redis/clients/jedis/ShardedCommandObjects.java#L101), the Jedis client calling `processKey` on the match argument, and this is what this PR also does.
We've had this patch running in production, and it seems to work well for us.
For further thought:
- Continuing looking at other Redis clients (e.g. Jedis), they outright [reject as invalid](https://github.com/redis/jedis/blob/869dc0bb6625b85c8bf15bf1361bde485a304338/src/main/java/redis/clients/jedis/ShardedCommandObjects.java#L98) any scan command that does not include a hash-tag. Presumably this has the advantage of users not being surprised when their scan produces no results when a random server is picked.
- Perhaps it would be sensible for go-redis to do the same also?1 parent 0bdc7dd commit c2c460f
3 files changed
+53
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
1353 | 1354 | | |
1354 | 1355 | | |
1355 | 1356 | | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1356 | 1360 | | |
1357 | 1361 | | |
1358 | 1362 | | |
| |||
1369 | 1373 | | |
1370 | 1374 | | |
1371 | 1375 | | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
1372 | 1379 | | |
1373 | 1380 | | |
1374 | 1381 | | |
| |||
1382 | 1389 | | |
1383 | 1390 | | |
1384 | 1391 | | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
1385 | 1395 | | |
1386 | 1396 | | |
1387 | 1397 | | |
| |||
1395 | 1405 | | |
1396 | 1406 | | |
1397 | 1407 | | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1398 | 1411 | | |
1399 | 1412 | | |
1400 | 1413 | | |
| |||
1408 | 1421 | | |
1409 | 1422 | | |
1410 | 1423 | | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
1411 | 1427 | | |
1412 | 1428 | | |
1413 | 1429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
59 | 71 | | |
60 | 72 | | |
61 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments