1
0
mirror of https://github.com/redis/go-redis.git synced 2025-04-17 20:17:02 +03:00

Rename probablistic commands with args (#2701)

Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
ofekshenawa 2023-09-20 10:42:09 +03:00 committed by GitHub
parent 736351c7cf
commit 33edd3de68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -24,7 +24,7 @@ type probabilisticCmdable interface {
BFReserve(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd BFReserve(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd
BFReserveExpansion(ctx context.Context, key string, errorRate float64, capacity, expansion int64) *StatusCmd BFReserveExpansion(ctx context.Context, key string, errorRate float64, capacity, expansion int64) *StatusCmd
BFReserveNonScaling(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd BFReserveNonScaling(ctx context.Context, key string, errorRate float64, capacity int64) *StatusCmd
BFReserveArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd BFReserveWithArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd
BFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd BFScanDump(ctx context.Context, key string, iterator int64) *ScanDumpCmd
BFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd BFLoadChunk(ctx context.Context, key string, iterator int64, data interface{}) *StatusCmd
@ -38,7 +38,7 @@ type probabilisticCmdable interface {
CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd
CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
CFReserve(ctx context.Context, key string, capacity int64) *StatusCmd CFReserve(ctx context.Context, key string, capacity int64) *StatusCmd
CFReserveArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd CFReserveWithArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd
CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd CFReserveExpansion(ctx context.Context, key string, capacity int64, expansion int64) *StatusCmd
CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize int64) *StatusCmd
CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd CFReserveMaxIterations(ctx context.Context, key string, capacity int64, maxiterations int64) *StatusCmd
@ -143,11 +143,11 @@ func (c cmdable) BFReserveNonScaling(ctx context.Context, key string, errorRate
return cmd return cmd
} }
// BFReserveArgs creates an empty Bloom filter with a single sub-filter // BFReserveWithArgs creates an empty Bloom filter with a single sub-filter
// for the initial specified capacity and with an upper bound error_rate. // for the initial specified capacity and with an upper bound error_rate.
// This function also allows for specifying additional options such as expansion rate and non-scaling behavior. // This function also allows for specifying additional options such as expansion rate and non-scaling behavior.
// For more information - https://redis.io/commands/bf.reserve/ // For more information - https://redis.io/commands/bf.reserve/
func (c cmdable) BFReserveArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd { func (c cmdable) BFReserveWithArgs(ctx context.Context, key string, options *BFReserveOptions) *StatusCmd {
args := []interface{}{"BF.RESERVE", key} args := []interface{}{"BF.RESERVE", key}
if options != nil { if options != nil {
if options.Error != 0 { if options.Error != 0 {
@ -493,10 +493,10 @@ func (c cmdable) CFReserveMaxIterations(ctx context.Context, key string, capacit
return cmd return cmd
} }
// CFReserveArgs creates an empty Cuckoo filter with the specified options. // CFReserveWithArgs creates an empty Cuckoo filter with the specified options.
// This function allows for specifying additional options such as bucket size and maximum number of iterations. // This function allows for specifying additional options such as bucket size and maximum number of iterations.
// For more information - https://redis.io/commands/cf.reserve/ // For more information - https://redis.io/commands/cf.reserve/
func (c cmdable) CFReserveArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd { func (c cmdable) CFReserveWithArgs(ctx context.Context, key string, options *CFReserveOptions) *StatusCmd {
args := []interface{}{"CF.RESERVE", key, options.Capacity} args := []interface{}{"CF.RESERVE", key, options.Capacity}
if options.BucketSize != 0 { if options.BucketSize != 0 {
args = append(args, "BUCKETSIZE", options.BucketSize) args = append(args, "BUCKETSIZE", options.BucketSize)
@ -679,7 +679,7 @@ func (c cmdable) CFInfo(ctx context.Context, key string) *CFInfoCmd {
// For more information - https://redis.io/commands/cf.insert/ // For more information - https://redis.io/commands/cf.insert/
func (c cmdable) CFInsert(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *BoolSliceCmd { func (c cmdable) CFInsert(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *BoolSliceCmd {
args := []interface{}{"CF.INSERT", key} args := []interface{}{"CF.INSERT", key}
args = c.getCfInsertArgs(args, options, elements...) args = c.getCfInsertWithArgs(args, options, elements...)
cmd := NewBoolSliceCmd(ctx, args...) cmd := NewBoolSliceCmd(ctx, args...)
_ = c(ctx, cmd) _ = c(ctx, cmd)
@ -693,14 +693,14 @@ func (c cmdable) CFInsert(ctx context.Context, key string, options *CFInsertOpti
// For more information - https://redis.io/commands/cf.insertnx/ // For more information - https://redis.io/commands/cf.insertnx/
func (c cmdable) CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd { func (c cmdable) CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd {
args := []interface{}{"CF.INSERTNX", key} args := []interface{}{"CF.INSERTNX", key}
args = c.getCfInsertArgs(args, options, elements...) args = c.getCfInsertWithArgs(args, options, elements...)
cmd := NewIntSliceCmd(ctx, args...) cmd := NewIntSliceCmd(ctx, args...)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
func (c cmdable) getCfInsertArgs(args []interface{}, options *CFInsertOptions, elements ...interface{}) []interface{} { func (c cmdable) getCfInsertWithArgs(args []interface{}, options *CFInsertOptions, elements ...interface{}) []interface{} {
if options != nil { if options != nil {
if options.Capacity != 0 { if options.Capacity != 0 {
args = append(args, "CAPACITY", options.Capacity) args = append(args, "CAPACITY", options.Capacity)

View File

@ -227,14 +227,14 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
Expect(infBefore).To(BeEquivalentTo(infAfter)) Expect(infBefore).To(BeEquivalentTo(infAfter))
}) })
It("should BFReserveArgs", Label("bloom", "bfreserveargs"), func() { It("should BFReserveWithArgs", Label("bloom", "bfreserveargs"), func() {
options := &redis.BFReserveOptions{ options := &redis.BFReserveOptions{
Capacity: 2000, Capacity: 2000,
Error: 0.001, Error: 0.001,
Expansion: 3, Expansion: 3,
NonScaling: false, NonScaling: false,
} }
err := client.BFReserveArgs(ctx, "testbf", options).Err() err := client.BFReserveWithArgs(ctx, "testbf", options).Err()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
result, err := client.BFInfo(ctx, "testbf").Result() result, err := client.BFInfo(ctx, "testbf").Result()
@ -352,7 +352,7 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
Expect(infBefore).To(BeEquivalentTo(infAfter)) Expect(infBefore).To(BeEquivalentTo(infAfter))
}) })
It("should CFInfo and CFReserveArgs", Label("cuckoo", "cfinfo", "cfreserveargs"), func() { It("should CFInfo and CFReserveWithArgs", Label("cuckoo", "cfinfo", "cfreserveargs"), func() {
args := &redis.CFReserveOptions{ args := &redis.CFReserveOptions{
Capacity: 2048, Capacity: 2048,
BucketSize: 3, BucketSize: 3,
@ -360,7 +360,7 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
Expansion: 2, Expansion: 2,
} }
err := client.CFReserveArgs(ctx, "testcf1", args).Err() err := client.CFReserveWithArgs(ctx, "testcf1", args).Err()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
result, err := client.CFInfo(ctx, "testcf1").Result() result, err := client.CFInfo(ctx, "testcf1").Result()