MCPcopy Index your code
hub / github.com/redis/go-redis / ExampleClient_bitcount

Function ExampleClient_bitcount

doctests/bitmap_tutorial_test.go:61–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func ExampleClient_bitcount() {
62 ctx := context.Background()
63
64 rdb := redis.NewClient(&redis.Options{
65 Addr: "localhost:6379",
66 Password: "", // no password docs
67 DB: 0, // use default DB
68 })
69
70 // REMOVE_START
71 // start with fresh database
72 rdb.FlushDB(ctx)
73 _, err := rdb.SetBit(ctx, "pings:2024-01-01-00:00", 123, 1).Result()
74
75 if err != nil {
76 panic(err)
77 }
78 // REMOVE_END
79
80 // STEP_START bitcount
81 res4, err := rdb.BitCount(ctx, "pings:2024-01-01-00:00",
82 &redis.BitCount{
83 Start: 0,
84 End: 456,
85 }).Result()
86
87 if err != nil {
88 panic(err)
89 }
90
91 fmt.Println(res4) // >>> 1
92 // STEP_END
93
94 // Output:
95 // 1
96}

Callers

nothing calls this directly

Calls 4

FlushDBMethod · 0.65
ResultMethod · 0.65
SetBitMethod · 0.65
BitCountMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…