mirror of https://github.com/go-redis/redis.git
Rename probablistic commands with args (#2701)
Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
parent
736351c7cf
commit
33edd3de68
|
@ -24,7 +24,7 @@ type probabilisticCmdable interface {
|
|||
BFReserve(ctx context.Context, key string, errorRate float64, capacity 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
|
||||
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
|
||||
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
|
||||
CFMExists(ctx context.Context, key string, elements ...interface{}) *BoolSliceCmd
|
||||
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
|
||||
CFReserveBucketSize(ctx context.Context, key string, capacity int64, bucketsize 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
|
||||
}
|
||||
|
||||
// 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.
|
||||
// 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/
|
||||
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}
|
||||
if options != nil {
|
||||
if options.Error != 0 {
|
||||
|
@ -493,10 +493,10 @@ func (c cmdable) CFReserveMaxIterations(ctx context.Context, key string, capacit
|
|||
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.
|
||||
// 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}
|
||||
if options.BucketSize != 0 {
|
||||
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/
|
||||
func (c cmdable) CFInsert(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *BoolSliceCmd {
|
||||
args := []interface{}{"CF.INSERT", key}
|
||||
args = c.getCfInsertArgs(args, options, elements...)
|
||||
args = c.getCfInsertWithArgs(args, options, elements...)
|
||||
|
||||
cmd := NewBoolSliceCmd(ctx, args...)
|
||||
_ = 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/
|
||||
func (c cmdable) CFInsertNX(ctx context.Context, key string, options *CFInsertOptions, elements ...interface{}) *IntSliceCmd {
|
||||
args := []interface{}{"CF.INSERTNX", key}
|
||||
args = c.getCfInsertArgs(args, options, elements...)
|
||||
args = c.getCfInsertWithArgs(args, options, elements...)
|
||||
|
||||
cmd := NewIntSliceCmd(ctx, args...)
|
||||
_ = c(ctx, 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.Capacity != 0 {
|
||||
args = append(args, "CAPACITY", options.Capacity)
|
||||
|
|
|
@ -227,14 +227,14 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expect(infBefore).To(BeEquivalentTo(infAfter))
|
||||
})
|
||||
|
||||
It("should BFReserveArgs", Label("bloom", "bfreserveargs"), func() {
|
||||
It("should BFReserveWithArgs", Label("bloom", "bfreserveargs"), func() {
|
||||
options := &redis.BFReserveOptions{
|
||||
Capacity: 2000,
|
||||
Error: 0.001,
|
||||
Expansion: 3,
|
||||
NonScaling: false,
|
||||
}
|
||||
err := client.BFReserveArgs(ctx, "testbf", options).Err()
|
||||
err := client.BFReserveWithArgs(ctx, "testbf", options).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
result, err := client.BFInfo(ctx, "testbf").Result()
|
||||
|
@ -352,7 +352,7 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
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{
|
||||
Capacity: 2048,
|
||||
BucketSize: 3,
|
||||
|
@ -360,7 +360,7 @@ var _ = Describe("Probabilistic commands", Label("probabilistic"), func() {
|
|||
Expansion: 2,
|
||||
}
|
||||
|
||||
err := client.CFReserveArgs(ctx, "testcf1", args).Err()
|
||||
err := client.CFReserveWithArgs(ctx, "testcf1", args).Err()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
result, err := client.CFInfo(ctx, "testcf1").Result()
|
||||
|
|
Loading…
Reference in New Issue