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 hstrlen command for hash #2843

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

Conversation

rfyiamcool
Copy link
Contributor

summary

Add HSTRLEN command for HASH.

https://redis.io/commands/hstrlen/

@rfyiamcool rfyiamcool force-pushed the feat/add_hstrlen_command_for_hash branch 2 times, most recently from 9bfbda2 to dd41c7d Compare December 18, 2023 16:21
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
@rfyiamcool rfyiamcool force-pushed the feat/add_hstrlen_command_for_hash branch from dd41c7d to 47591c8 Compare December 19, 2023 15:57
@@ -172,3 +173,9 @@ func (c cmdable) HScan(ctx context.Context, key string, cursor uint64, match str
_ = c(ctx, cmd)
return cmd
}

func (c cmdable) HStrLen(ctx context.Context, key, field string) *IntCmd {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe changing the type of field to interface{}?
To enhance flexibility by supporting multiple data types and simplifying API usage across different caller scenario.
WDYT?

Copy link
Contributor Author

@rfyiamcool rfyiamcool Feb 20, 2024

Choose a reason for hiding this comment

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

I found type of field in hash commands is string type, so I need to be consistent with the other hash commands ? 😁

// hash_commands.go:5
type HashCmdable interface {
	HDel(ctx context.Context, key string, fields ...string) *IntCmd
	HExists(ctx context.Context, key, field string) *BoolCmd
	HGet(ctx context.Context, key, field string) *StringCmd
	HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd
	HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd
	HMGet(ctx context.Context, key string, fields ...string) *SliceCmd
	HSet(ctx context.Context, key string, values ...interface{}) *IntCmd
	HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd
	HSetNX(ctx context.Context, key, field string, value interface{}) *BoolCmd
	HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd
	HVals(ctx context.Context, key string) *StringSliceCmd
	HRandField(ctx context.Context, key string, count int) *StringSliceCmd
	HRandFieldWithValues(ctx context.Context, key string, count int) *KeyValueSliceCmd
	HStrLen(ctx context.Context, key, field string) *IntCmd
}

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.

2 participants