Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add unit field to bitcount #538

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SoulPancake
Copy link
Contributor

@SoulPancake
Copy link
Contributor Author

@rueian
Do we need to also do it for
func (c CacheCompat) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd
for this to work?

@rueian
Copy link
Collaborator

rueian commented Apr 27, 2024

CacheCompat) BitCount(ctx context.Context, ke

Yes, we should support the Unit there too.

resp = c.client.Do(ctx, c.client.B().Bitcount().Key(key).Build())
} else {
resp = c.client.Do(ctx, c.client.B().Bitcount().Key(key).Start(bitCount.Start).End(bitCount.End).Build())
resp := c.client.Do(ctx, c.client.B().Bitcount().Key(key).Bit().Build()) // Default to BIT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SoulPancake,

We can't use .Bit() as default because it is only supported on Redis >= 7. We should keep the original behavior.

switch bitCount.Unit {
case BitCountIndexByte:
resp = c.client.Do(ctx, builder.Byte().Build()) // Handling for BYTE
case BitCountIndexBit, "": // Default to BIT if not specified
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. we can't use .Bit() as default in the case of "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants