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

Support for Adding Map type in Input of HSet #649

Open
atharva29 opened this issue Oct 16, 2024 · 2 comments
Open

Support for Adding Map type in Input of HSet #649

atharva29 opened this issue Oct 16, 2024 · 2 comments

Comments

@atharva29
Copy link

atharva29 commented Oct 16, 2024

Currently for values its accepting '[]any' for
'rueidiscompat.Cmdable.HSet(ctx context.Context, key string, values ...any) '

It should accept input in form of map[string]interface{} , as most of the developers have their values in the form of structs.
Developers can marshal and then unmarshal it to convert their structure into map, no need to convert it into []any.
eg.
``
type CustInfo struct {
CustomerID string json:"customer_id"
Name string `json:"name"`
}

using json.marshal and json.unmarshal we can easily convert it into map and pass it in
rueidiscompat.Cmdable.HSetV1(ctx context.Context, key string, values map[string]interface{})
``

@atharva29
Copy link
Author

atharva29 commented Oct 16, 2024

if this issue is marks as feature then
i would be happy to add PR for this feature,

@atharva29 atharva29 changed the title Support for Adding Map type in Input of HSET Support for Adding Map type in Input of HSET & HMSet Oct 16, 2024
@atharva29 atharva29 changed the title Support for Adding Map type in Input of HSET & HMSet Support for Adding Map type in Input of HMSet Oct 16, 2024
@atharva29 atharva29 changed the title Support for Adding Map type in Input of HMSet Support for Adding Map type in Input of HSet Oct 16, 2024
@rueian
Copy link
Collaborator

rueian commented Oct 16, 2024

Hi @atharva29,

Thank you for the proposal. But map[string]interface{} is too loose for HSET. Remember that HSET can't accept nested structures in one field. So, json.Marshal is also inappropriate for HSET. Use JSON.SET instead.

In terms of performance, IMO, the FieldValueIter by #625 is the best way to use HSET without additional intermediate map/slice allocation.

By the way, I think we already made rueidiscompat.Cmdable.HSet compatible with go-redis, that you can already put a single map[string]interface{} without nested structures and it will turn the map into arguments slice.

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

No branches or pull requests

2 participants