Junior — Middle
Can you describe the Redis commands you have used in your practice?
sobes.tech AI
Answer from AI
In working with Redis, I used the following commands:
SETandGETfor writing and reading simple key-value pairs.HSETandHGETfor working with hash tables, for example, to store object properties.LPUSHandLRANGEfor working with lists, for example, to implement queues.EXPIREto set the lifetime of keys.DELto delete keys.
Example of usage in Go with the go-redis library:
import (
"context"
"github.com/go-redis/redis/v8"
)
ctx := context.Background()
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
// Setting a value
err := rdb.Set(ctx, "key", "value", 0).Err()
// Getting a value
val, err := rdb.Get(ctx, "key").Result()