Skip to content

Commit 15a40c2

Browse files
authored
Merge branch 'master' into ndyakov/CAE-1088-resp3-notification-handlers
2 parents c44c8b5 + 7ac4021 commit 15a40c2

File tree

7 files changed

+149
-3
lines changed

7 files changed

+149
-3
lines changed

.github/actions/run-tests/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ runs:
2525
2626
# Mapping of redis version to redis testing containers
2727
declare -A redis_version_mapping=(
28+
["8.2.x"]="8.2-M01-pre"
2829
["8.0.x"]="8.0.2"
2930
["7.4.x"]="rs-7.4.0-v5"
3031
["7.2.x"]="rs-7.2.0-v17"

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
redis-version:
21+
- "8.2.x" # Redis CE 8.2
2122
- "8.0.x" # Redis CE 8.0
2223
- "7.4.x" # Redis stack 7.4
2324
go-version:
@@ -43,6 +44,7 @@ jobs:
4344
4445
# Mapping of redis version to redis testing containers
4546
declare -A redis_version_mapping=(
47+
["8.2.x"]="8.2-M01-pre"
4648
["8.0.x"]="8.0.2"
4749
["7.4.x"]="rs-7.4.0-v5"
4850
)
@@ -72,6 +74,7 @@ jobs:
7274
fail-fast: false
7375
matrix:
7476
redis-version:
77+
- "8.2.x" # Redis CE 8.2
7578
- "8.0.x" # Redis CE 8.0
7679
- "7.4.x" # Redis stack 7.4
7780
- "7.2.x" # Redis stack 7.2

bitmap_commands.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ type BitMapCmdable interface {
1212
BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd
1313
BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd
1414
BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd
15+
BitOpDiff(ctx context.Context, destKey string, keys ...string) *IntCmd
16+
BitOpDiff1(ctx context.Context, destKey string, keys ...string) *IntCmd
17+
BitOpAndOr(ctx context.Context, destKey string, keys ...string) *IntCmd
18+
BitOpOne(ctx context.Context, destKey string, keys ...string) *IntCmd
1519
BitOpNot(ctx context.Context, destKey string, key string) *IntCmd
1620
BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
1721
BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd
@@ -78,22 +82,50 @@ func (c cmdable) bitOp(ctx context.Context, op, destKey string, keys ...string)
7882
return cmd
7983
}
8084

85+
// BitOpAnd creates a new bitmap in which users are members of all given bitmaps
8186
func (c cmdable) BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd {
8287
return c.bitOp(ctx, "and", destKey, keys...)
8388
}
8489

90+
// BitOpOr creates a new bitmap in which users are member of at least one given bitmap
8591
func (c cmdable) BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd {
8692
return c.bitOp(ctx, "or", destKey, keys...)
8793
}
8894

95+
// BitOpXor creates a new bitmap in which users are the result of XORing all given bitmaps
8996
func (c cmdable) BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd {
9097
return c.bitOp(ctx, "xor", destKey, keys...)
9198
}
9299

100+
// BitOpNot creates a new bitmap in which users are not members of a given bitmap
93101
func (c cmdable) BitOpNot(ctx context.Context, destKey string, key string) *IntCmd {
94102
return c.bitOp(ctx, "not", destKey, key)
95103
}
96104

105+
// BitOpDiff creates a new bitmap in which users are members of bitmap X but not of any of bitmaps Y1, Y2, …
106+
// Introduced with Redis 8.2
107+
func (c cmdable) BitOpDiff(ctx context.Context, destKey string, keys ...string) *IntCmd {
108+
return c.bitOp(ctx, "diff", destKey, keys...)
109+
}
110+
111+
// BitOpDiff1 creates a new bitmap in which users are members of one or more of bitmaps Y1, Y2, … but not members of bitmap X
112+
// Introduced with Redis 8.2
113+
func (c cmdable) BitOpDiff1(ctx context.Context, destKey string, keys ...string) *IntCmd {
114+
return c.bitOp(ctx, "diff1", destKey, keys...)
115+
}
116+
117+
// BitOpAndOr creates a new bitmap in which users are members of bitmap X and also members of one or more of bitmaps Y1, Y2, …
118+
// Introduced with Redis 8.2
119+
func (c cmdable) BitOpAndOr(ctx context.Context, destKey string, keys ...string) *IntCmd {
120+
return c.bitOp(ctx, "andor", destKey, keys...)
121+
}
122+
123+
// BitOpOne creates a new bitmap in which users are members of exactly one of the given bitmaps
124+
// Introduced with Redis 8.2
125+
func (c cmdable) BitOpOne(ctx context.Context, destKey string, keys ...string) *IntCmd {
126+
return c.bitOp(ctx, "one", destKey, keys...)
127+
}
128+
97129
// BitPos is an API before Redis version 7.0, cmd: bitpos key bit start end
98130
// if you need the `byte | bit` parameter, please use `BitPosSpan`.
99131
func (c cmdable) BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd {

command.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,6 +5197,9 @@ type ClientInfo struct {
51975197
OutputListLength int // oll, output list length (replies are queued in this list when the buffer is full)
51985198
OutputMemory int // omem, output buffer memory usage
51995199
TotalMemory int // tot-mem, total memory consumed by this client in its various buffers
5200+
TotalNetIn int // tot-net-in, total network input
5201+
TotalNetOut int // tot-net-out, total network output
5202+
TotalCmds int // tot-cmds, total number of commands processed
52005203
IoThread int // io-thread id
52015204
Events string // file descriptor events (see below)
52025205
LastCmd string // cmd, last command played
@@ -5362,6 +5365,12 @@ func parseClientInfo(txt string) (info *ClientInfo, err error) {
53625365
info.OutputMemory, err = strconv.Atoi(val)
53635366
case "tot-mem":
53645367
info.TotalMemory, err = strconv.Atoi(val)
5368+
case "tot-net-in":
5369+
info.TotalNetIn, err = strconv.Atoi(val)
5370+
case "tot-net-out":
5371+
info.TotalNetOut, err = strconv.Atoi(val)
5372+
case "tot-cmds":
5373+
info.TotalCmds, err = strconv.Atoi(val)
53655374
case "events":
53665375
info.Events = val
53675376
case "cmd":

commands_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,82 @@ var _ = Describe("Commands", func() {
14691469
Expect(get.Val()).To(Equal("\xf0"))
14701470
})
14711471

1472+
It("should BitOpDiff", Label("NonRedisEnterprise"), func() {
1473+
SkipBeforeRedisVersion(8.2, "BITOP DIFF is available since Redis 8.2")
1474+
set := client.Set(ctx, "key1", "\xff", 0)
1475+
Expect(set.Err()).NotTo(HaveOccurred())
1476+
Expect(set.Val()).To(Equal("OK"))
1477+
1478+
set = client.Set(ctx, "key2", "\x0f", 0)
1479+
Expect(set.Err()).NotTo(HaveOccurred())
1480+
Expect(set.Val()).To(Equal("OK"))
1481+
1482+
bitOpDiff := client.BitOpDiff(ctx, "dest", "key1", "key2")
1483+
Expect(bitOpDiff.Err()).NotTo(HaveOccurred())
1484+
Expect(bitOpDiff.Val()).To(Equal(int64(1)))
1485+
1486+
get := client.Get(ctx, "dest")
1487+
Expect(get.Err()).NotTo(HaveOccurred())
1488+
Expect(get.Val()).To(Equal("\xf0"))
1489+
})
1490+
1491+
It("should BitOpDiff1", Label("NonRedisEnterprise"), func() {
1492+
SkipBeforeRedisVersion(8.2, "BITOP DIFF is available since Redis 8.2")
1493+
set := client.Set(ctx, "key1", "\xff", 0)
1494+
Expect(set.Err()).NotTo(HaveOccurred())
1495+
Expect(set.Val()).To(Equal("OK"))
1496+
1497+
set = client.Set(ctx, "key2", "\x0f", 0)
1498+
Expect(set.Err()).NotTo(HaveOccurred())
1499+
Expect(set.Val()).To(Equal("OK"))
1500+
1501+
bitOpDiff1 := client.BitOpDiff1(ctx, "dest", "key1", "key2")
1502+
Expect(bitOpDiff1.Err()).NotTo(HaveOccurred())
1503+
Expect(bitOpDiff1.Val()).To(Equal(int64(1)))
1504+
1505+
get := client.Get(ctx, "dest")
1506+
Expect(get.Err()).NotTo(HaveOccurred())
1507+
Expect(get.Val()).To(Equal("\x00"))
1508+
})
1509+
1510+
It("should BitOpAndOr", Label("NonRedisEnterprise"), func() {
1511+
SkipBeforeRedisVersion(8.2, "BITOP ANDOR is available since Redis 8.2")
1512+
set := client.Set(ctx, "key1", "\xff", 0)
1513+
Expect(set.Err()).NotTo(HaveOccurred())
1514+
Expect(set.Val()).To(Equal("OK"))
1515+
1516+
set = client.Set(ctx, "key2", "\x0f", 0)
1517+
Expect(set.Err()).NotTo(HaveOccurred())
1518+
Expect(set.Val()).To(Equal("OK"))
1519+
1520+
bitOpAndOr := client.BitOpAndOr(ctx, "dest", "key1", "key2")
1521+
Expect(bitOpAndOr.Err()).NotTo(HaveOccurred())
1522+
Expect(bitOpAndOr.Val()).To(Equal(int64(1)))
1523+
1524+
get := client.Get(ctx, "dest")
1525+
Expect(get.Err()).NotTo(HaveOccurred())
1526+
Expect(get.Val()).To(Equal("\x0f"))
1527+
})
1528+
1529+
It("should BitOpOne", Label("NonRedisEnterprise"), func() {
1530+
SkipBeforeRedisVersion(8.2, "BITOP ONE is available since Redis 8.2")
1531+
set := client.Set(ctx, "key1", "\xff", 0)
1532+
Expect(set.Err()).NotTo(HaveOccurred())
1533+
Expect(set.Val()).To(Equal("OK"))
1534+
1535+
set = client.Set(ctx, "key2", "\x0f", 0)
1536+
Expect(set.Err()).NotTo(HaveOccurred())
1537+
Expect(set.Val()).To(Equal("OK"))
1538+
1539+
bitOpOne := client.BitOpOne(ctx, "dest", "key1", "key2")
1540+
Expect(bitOpOne.Err()).NotTo(HaveOccurred())
1541+
Expect(bitOpOne.Val()).To(Equal(int64(1)))
1542+
1543+
get := client.Get(ctx, "dest")
1544+
Expect(get.Err()).NotTo(HaveOccurred())
1545+
Expect(get.Val()).To(Equal("\xf0"))
1546+
})
1547+
14721548
It("should BitOpNot", Label("NonRedisEnterprise"), func() {
14731549
set := client.Set(ctx, "key1", "\x00", 0)
14741550
Expect(set.Err()).NotTo(HaveOccurred())

ring.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ func (c *Ring) generalProcessPipeline(
798798
}
799799

800800
var wg sync.WaitGroup
801+
errs := make(chan error, len(cmdsMap))
802+
801803
for hash, cmds := range cmdsMap {
802804
wg.Add(1)
803805
go func(hash string, cmds []Cmder) {
@@ -810,16 +812,24 @@ func (c *Ring) generalProcessPipeline(
810812
return
811813
}
812814

815+
hook := shard.Client.processPipelineHook
813816
if tx {
814817
cmds = wrapMultiExec(ctx, cmds)
815-
_ = shard.Client.processTxPipelineHook(ctx, cmds)
816-
} else {
817-
_ = shard.Client.processPipelineHook(ctx, cmds)
818+
hook = shard.Client.processTxPipelineHook
819+
}
820+
821+
if err = hook(ctx, cmds); err != nil {
822+
errs <- err
818823
}
819824
}(hash, cmds)
820825
}
821826

822827
wg.Wait()
828+
close(errs)
829+
830+
if err := <-errs; err != nil {
831+
return err
832+
}
823833
return cmdsFirstErr(cmds)
824834
}
825835

ring_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,21 @@ var _ = Describe("Redis Ring", func() {
277277
Expect(ringShard1.Info(ctx).Val()).ToNot(ContainSubstring("keys="))
278278
Expect(ringShard2.Info(ctx).Val()).To(ContainSubstring("keys=100"))
279279
})
280+
281+
It("return dial timeout error", func() {
282+
opt := redisRingOptions()
283+
opt.DialTimeout = 250 * time.Millisecond
284+
opt.Addrs = map[string]string{"ringShardNotExist": ":1997"}
285+
ring = redis.NewRing(opt)
286+
287+
_, err := ring.Pipelined(ctx, func(pipe redis.Pipeliner) error {
288+
pipe.HSet(ctx, "key", "value")
289+
pipe.Expire(ctx, "key", time.Minute)
290+
return nil
291+
})
292+
293+
Expect(err).To(HaveOccurred())
294+
})
280295
})
281296

282297
Describe("new client callback", func() {

0 commit comments

Comments
 (0)