https://github.com/go-spring/starter-go-redis
「仅发布」 go-redis 启动器 ( starter for go-redis )
https://github.com/go-spring/starter-go-redis
go-redis go-spring redis
Last synced: 5 months ago
JSON representation
「仅发布」 go-redis 启动器 ( starter for go-redis )
- Host: GitHub
- URL: https://github.com/go-spring/starter-go-redis
- Owner: go-spring
- License: apache-2.0
- Archived: true
- Created: 2020-08-08T10:28:40.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-09T09:39:36.000Z (over 3 years ago)
- Last Synced: 2025-03-30T08:01:52.473Z (about 1 year ago)
- Topics: go-redis, go-spring, redis
- Language: Go
- Homepage: https://go-spring.com
- Size: 381 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# starter-go-redis
[English](README.md) | [中文](README_CN.md)
> The project has been officially released, welcome to use!
`starter-go-redis` provides a Redis client wrapper based on go-redis,
making it easy to integrate and use Redis in Go-Spring applications.
## Installation
```bash
go get github.com/go-spring/starter-go-redis
```
## Quick Start
### 1. Import the `starter-go-redis` Package
Refer to the [example.go](example/example.go) file.
```go
import _ "github.com/go-spring/starter-go-redis"
```
### 2. Configure the Redis Instance
Add Redis configuration in your project’s [configuration file](example/conf/app.properties), for example:
```properties
spring.go-redis.main.addr=127.0.0.1:6379
```
### 3. Inject the Redis Instance
Refer to the [example.go](example/example.go) file.
```go
import "github.com/redis/go-redis/v9"
type Service struct {
Redis *redis.Client `autowire:""`
}
```
### 4. Use the Redis Instance
Refer to the [example.go](example/example.go) file.
```go
str, err := s.Redis.Get(r.Context(), "key").Result()
str, err := s.Redis.Set(r.Context(), "key", "value", 0).Result()
```
## Advanced Features
* **Supports multiple Redis instances**: You can define multiple Redis instances in the configuration file and reference
them by name in your project.
* **Support Redis extensions**: You can extend Redis functionality by implementing the `Driver` interface — see the
example implementation `AnotherRedisDriver`.