Are commands run lazily? #2308
-
In the docs executing-commands it says the command can be stored and then the val/error accessed later. Does this mean the command is not executed until the val/error are asked for or does the command get executed right away? For example, if try storing the command like such does it run when I call var cmd *redis.StatusCmd
if foo == true {
cmd = rdb.Get(ctx, "foo")
} else {
cmd = rdb.Get(ctx, "bar")
}
val, err := cmd.Result() Thanks for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Commands run synchronously when you execute |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response, that was exactly what I was looking for 😄. |
Beta Was this translation helpful? Give feedback.
Commands run synchronously when you execute
rdb.Get(ctx, "foo")
, but in pipelines they run asynchronously when you executepipe.Exec(ctx)