Back to course

Working with Redis: Caching

Go (Golang) for Cloud-Native Microservices

Speeding up with Redis

Caching frequently accessed data in Redis can drastically reduce database load.

go rdb := redis.NewClient(&redis.Options{Addr: "localhost:6379"})

// Set a value with expiration err := rdb.Set(ctx, "key", "value", time.Minute).Err()

// Get a value val, err := rdb.Get(ctx, "key").Result()