Skip to content

Commit 097b94a

Browse files
authored
Merge pull request #1680 from lhchavez/add-setargs-to-pipeliner
Make SetArgs available to Pipeliner
2 parents 1564bc6 + 4ffcd9b commit 097b94a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ type Cmdable interface {
124124
MSet(ctx context.Context, values ...interface{}) *StatusCmd
125125
MSetNX(ctx context.Context, values ...interface{}) *BoolCmd
126126
Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
127+
SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd
127128
SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd
128129
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd
129130
SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd

commands_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,23 @@ var _ = Describe("Commands", func() {
14001400
Expect(val).To(Equal("hello"))
14011401
})
14021402

1403+
It("should Pipelined SetArgs with Get and key exists", func() {
1404+
e := client.Set(ctx, "key", "hello", 0)
1405+
Expect(e.Err()).NotTo(HaveOccurred())
1406+
1407+
args := redis.SetArgs{
1408+
Get: true,
1409+
}
1410+
1411+
pipe := client.Pipeline()
1412+
setArgs := pipe.SetArgs(ctx, "key", "world", args)
1413+
_, err := pipe.Exec(ctx)
1414+
Expect(err).NotTo(HaveOccurred())
1415+
1416+
Expect(setArgs.Err()).NotTo(HaveOccurred())
1417+
Expect(setArgs.Val()).To(Equal("hello"))
1418+
})
1419+
14031420
It("should Set with expiration", func() {
14041421
err := client.Set(ctx, "key", "hello", 100*time.Millisecond).Err()
14051422
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)