-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Where is a basic example? #461
Comments
The examples in godoc cover this pretty well. Here's how to establish a new connection: And this snippet shows you how to first write and then read a string: |
Thank you. What I want is to get list rows that have keys Here is my code conn, err := redis.DialURL("redis://172.17.0.1:6379")
defer conn.Close()
if err != nil {
panic(err.Error())
}
res, err := conn.Do("KEYS", "p_1:*")
if err != nil {
panic(err.Error())
}
res, err = redis.Values(conn.Do("MGET", res))
if err != nil {
panic(err.Error())
}
fmt.Println(res)
|
Look at the docs that I linked to in my earlier post, when reading a string with "GET" you should use the conversion function |
First, let me say how I am thankful for your time. I looked at docs but I can't get it. When I get keys I have a result. But when I MGET I have I do not use GET. I use KEYS and that supposed to return array so perhaps I have to convert KEYS to something else. Could you look at my code and tell what is missing? |
You want: keys, err := redis.Strings(conn.Do("KEYS", "p_1:*"))
if err != nil {
panic(err.Error())
}
for _, k := range keys {
fmt.Println(k)
} |
@stevenh yes that ш can do. ш can list of keys. I cannot convert this list to appropriate format to use MGET |
no conversion needed just pass the result using variadic expansion e.g. vals, err := redis.Values(conn.Do("HGET", keys...)) |
Do I miss anything? I can't find a basil example just connect and set value and then get the same value. Without pool or cluster. I cannot figure out even how to connect to DB.
I know that for someone pro in Golang that all is obvious, but I am first week Go developer and not everything is obvious and I need examples.
The text was updated successfully, but these errors were encountered: