Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulPancake committed May 18, 2024
1 parent b93fec7 commit acf06d2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 46 deletions.
5 changes: 0 additions & 5 deletions internal/cmds/gen_bf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion internal/cmds/gen_bf_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions internal/cmds/gen_cf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion internal/cmds/gen_cf_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions rueidiscompat/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5050,12 +5050,6 @@ func (c CacheCompat) ZScore(ctx context.Context, key, member string) *FloatCmd {
return newFloatCmd(resp)
}

func (c CacheCompat) BFAdd(ctx context.Context, key string, element interface{}) *BoolCmd {
cmd := c.client.B().BfAdd().Key(key).Item(str(element)).Cache()
resp := c.client.DoCache(ctx, cmd, c.ttl)
return newBoolCmd(resp)
}

func (c CacheCompat) BFExists(ctx context.Context, key string, element interface{}) *BoolCmd {
cmd := c.client.B().BfExists().Key(key).Item(str(element)).Cache()
resp := c.client.DoCache(ctx, cmd, c.ttl)
Expand Down Expand Up @@ -5115,11 +5109,6 @@ func (c CacheCompat) BFInfoExpansion(ctx context.Context, key string) *BFInfoCmd
return newBFInfoCmd(resp)
}

func (c *CacheCompat) CFAdd(ctx context.Context, key string, element interface{}) *BoolCmd {
cmd := c.client.B().CfAdd().Key(key).Item(str(element)).Cache()
return newBoolCmd(c.client.DoCache(ctx, cmd, c.ttl))
}

func (c *CacheCompat) CFCount(ctx context.Context, key string, element interface{}) *IntCmd {
cmd := c.client.B().CfCount().Key(key).Item(str(element)).Cache()
return newIntCmd(c.client.DoCache(ctx, cmd, c.ttl))
Expand Down
51 changes: 28 additions & 23 deletions rueidiscompat/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8396,20 +8396,16 @@ func testAdapterCache(resp3 bool) {
}}))
})

It("should BFAdd", func() {
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
})

It("should BFExists", func() {
bfExists := adapter.Cache(time.Hour).BFExists(ctx, "key", "element")
Expect(bfExists.Err()).NotTo(HaveOccurred())
})

It("should BFInfo", func() {
// Add the key
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
bfAdd, err := adapter.BFAdd(ctx, "key", "element").Result()

Expect(err).NotTo(HaveOccurred())
Expect(bfAdd).To(BeTrue())

// Check if the key exists
bfExists := adapter.Cache(time.Hour).BFExists(ctx, "key", "element")
Expand All @@ -8422,8 +8418,10 @@ func testAdapterCache(resp3 bool) {

It("should BFInfoArg with CAPACITY", func() {
// Add the key
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
bfAdd, err := adapter.BFAdd(ctx, "key", "element").Result()

Expect(err).NotTo(HaveOccurred())
Expect(bfAdd).To(BeTrue())

// Call BFInfoArg with CAPACITY
bfInfo := adapter.Cache(time.Hour).BFInfoArg(ctx, "key", "CAPACITY")
Expand All @@ -8432,8 +8430,10 @@ func testAdapterCache(resp3 bool) {

It("should BFInfoArg with SIZE", func() {
// Add the key
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
bfAdd, err := adapter.BFAdd(ctx, "key", "element").Result()

Expect(err).NotTo(HaveOccurred())
Expect(bfAdd).To(BeTrue())

// Call BFInfoArg with SIZE
bfInfo := adapter.Cache(time.Hour).BFInfoArg(ctx, "key", "SIZE")
Expand All @@ -8442,8 +8442,10 @@ func testAdapterCache(resp3 bool) {

It("should BFInfoArg with FILTERS", func() {
// Add the key
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
bfAdd, err := adapter.BFAdd(ctx, "key", "element").Result()

Expect(err).NotTo(HaveOccurred())
Expect(bfAdd).To(BeTrue())

// Call BFInfoArg with FILTERS
bfInfo := adapter.Cache(time.Hour).BFInfoArg(ctx, "key", "FILTERS")
Expand All @@ -8452,8 +8454,10 @@ func testAdapterCache(resp3 bool) {

It("should BFInfoArg with ITEMS", func() {
// Add the key
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
bfAdd, err := adapter.BFAdd(ctx, "key", "element").Result()

Expect(err).NotTo(HaveOccurred())
Expect(bfAdd).To(BeTrue())

// Call BFInfoArg with ITEMS
bfInfo := adapter.Cache(time.Hour).BFInfoArg(ctx, "key", "ITEMS")
Expand All @@ -8462,29 +8466,30 @@ func testAdapterCache(resp3 bool) {

It("should BFInfoArg with EXPANSION", func() {
// Add the key
bfAdd := adapter.Cache(time.Hour).BFAdd(ctx, "key", "element")
Expect(bfAdd.Err()).NotTo(HaveOccurred())
bfAdd, err := adapter.BFAdd(ctx, "key", "element").Result()

Expect(err).NotTo(HaveOccurred())
Expect(bfAdd).To(BeTrue())

// Call BFInfoArg with EXPANSION
bfInfo := adapter.Cache(time.Hour).BFInfoArg(ctx, "key", "EXPANSION")
Expect(bfInfo.Err()).NotTo(HaveOccurred())
})

It("should CFCount", func() {
cache := adapter.Cache(time.Hour)
// Add the key
cfAdd := cache.CFCount(ctx, "cf_key", "element")
cfAdd := adapter.CFAdd(ctx, "cf_key", "element")
Expect(cfAdd.Err()).NotTo(HaveOccurred())

// Call CFCount
cache := adapter.Cache(time.Hour)
cfCount := cache.CFCount(ctx, "cf_key", "element")
Expect(cfCount.Err()).NotTo(HaveOccurred())
})

It("should CFExists", func() {
cache := adapter.Cache(time.Hour)
// Add the key
cfAdd := cache.CFExists(ctx, "cf_key", "element")
cfAdd := adapter.CFAdd(ctx, "cf_key", "element")
Expect(cfAdd.Err()).NotTo(HaveOccurred())

// Call CFExists
Expand All @@ -8496,7 +8501,7 @@ func testAdapterCache(resp3 bool) {
cache := adapter.Cache(time.Hour)

// Add the key
cfAdd := cache.CFAdd(ctx, "cf_key", "element")
cfAdd := adapter.CFAdd(ctx, "cf_key", "element")
Expect(cfAdd.Err()).NotTo(HaveOccurred())

// Call CFInfo
Expand Down

0 comments on commit acf06d2

Please sign in to comment.