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

Convenient methods for each redis commands ? #72

Closed
tbruyelle opened this issue Jun 26, 2014 · 2 comments
Closed

Convenient methods for each redis commands ? #72

tbruyelle opened this issue Jun 26, 2014 · 2 comments
Assignees

Comments

@tbruyelle
Copy link

I wonder why there is no convenient methods for each redis command.

For instance instead of :

values, err := redis.Values(conn.Do("HGETALL", sym))
if err != nil {
  log.Fatal(err)
}
var stock Stock
if err := redis.ScanStruct(values, &stock); err != nil {
  log.Fatal(err)
}

It would be nice to have :

var stock Stock
if err := conn.Hgetall("key", &stock); err!= nil {
  log.Fatal(err)
}

With the following naive implementation :

func (c *Conn) Hgetall(key string, data interface{}) error {
values, err := redis.Values(conn.Do("HGETALL", key))
if err != nil {
  return err
}
if err := redis.ScanStruct(values, data); err != nil {
  return err
}
return nil
}

The implementation could be improved with the detection of data type and so invoking the corresponding Scan* function.

@garyburd garyburd self-assigned this Jun 27, 2014
@garyburd
Copy link
Member

I did not add convenience functions for the following reasons:

  • It's not clear that the functions carry their weight. It's an extra layer for the application developer to learn with not a large amount of benefit.
  • I could not find a design that works in pipelines and transactions.

@tbruyelle
Copy link
Author

Thanks for the explanation

@gomodule gomodule locked and limited conversation to collaborators Dec 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants