[Awesome Go] Use go-redis to access Redis Type-safe
Redis client for Golang
go-redis is a Type-safe Redis client for Golang.
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.
Redis 3 commands except QUIT, MONITOR, and SYNC.
Automatic connection pooling with circuit breaker support.
Pipeline and TxPipeline.
Cluster of Redis Servers without using cluster mode and Redis Sentinel.
go-redis supports 2 last Go versions and requires a Go version with modules support. So make sure to initialize a Go module:
go mod init github.com/my/repo
And then install
go-redis/v8 (note v8 in the import; omitting it is a popular mistake):
go get -u github.com/go-redis/redis/v8
Look and feel
Some corner cases:
// SET key value EX 10 NX
 go-redis/redis: Type-safe Redis client for Golang - https://github.com/go-redis/redis
 Redis client - Type-safe Redis client for Go - https://redis.uptrace.dev/
 redis · pkg.go.dev - https://pkg.go.dev/github.com/go-redis/redis/v8