Sobes.tech
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:

  • SET and GET for writing and reading simple key-value pairs.
  • HSET and HGET for working with hash tables, for example, to store object properties.
  • LPUSH and LRANGE for working with lists, for example, to implement queues.
  • EXPIRE to set the lifetime of keys.
  • DEL to 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()