https://github.com/icowan/redis-client
redis连接集合
https://github.com/icowan/redis-client
redis redis-cluster-client
Last synced: about 1 month ago
JSON representation
redis连接集合
- Host: GitHub
- URL: https://github.com/icowan/redis-client
- Owner: icowan
- Created: 2020-08-24T01:28:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T10:27:04.000Z (about 2 years ago)
- Last Synced: 2024-06-21T21:03:59.465Z (11 months ago)
- Topics: redis, redis-cluster-client
- Language: Go
- Homepage:
- Size: 81.1 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# redis client
## 使用
```bash
go get github.com/icowan/redis-client
```## 单点Redis
```golang
rds, err := NewRedisClient("127.0.0.1:6379", "admin", "", 1)
if err != nil {
log.Fatal(err)
}
defer func() {
_ = rds.Close()
}()_ = rds.Set("hello", "world", time.Second*10)
v, err := rds.Get("hello")
if err != nil {
log.Fatal()
}log.Print(v)
```## 集群Redis
```golang
rds, err := NewRedisClient("127.0.0.1:6379,127.0.0.1:7379,127.0.0.1:8379", "admin", "", 1)
if err != nil {
log.Fatal(err)
}
defer func() {
_ = rds.Close()
}()_ = rds.Set("hello", "world", time.Second*10)
v, err := rds.Get("hello")
if err != nil {
log.Fatal()
}log.Print(v)
```