https://github.com/44437/rediscache
This package makes it easy to abstract your Redis connection and utilize Get and Set methods.
https://github.com/44437/rediscache
go golang redis redis-cache redis-client redis-database redis-server
Last synced: 8 months ago
JSON representation
This package makes it easy to abstract your Redis connection and utilize Get and Set methods.
- Host: GitHub
- URL: https://github.com/44437/rediscache
- Owner: 44437
- Created: 2022-05-06T18:06:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-07T07:37:34.000Z (about 4 years ago)
- Last Synced: 2025-04-14T07:56:16.584Z (about 1 year ago)
- Topics: go, golang, redis, redis-cache, redis-client, redis-database, redis-server
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rediscache
[](https://github.com/ercantopuz/rediscache/actions/workflows/ci.yaml)
[](https://codecov.io/gh/ercantopuz/rediscache)
[](https://github.com/ercantopuz/rediscache/releases)
[](https://goreportcard.com/report/github.com/ercantopuz/rediscache)
## Installation
This package makes it easy to abstract your Redis connection and use Get and Set methods.
```sh
go get github.com/ercantopuz/rediscache
```
Import it in your code:
```go
import "github.com/ercantopuz/rediscache"
```
### Quick start
```go
package main
import "github.com/ercantopuz/rediscache"
func main() {
// It has all the properties of the redis.Options
redisCacheOptions := rediscache.Options{
Addr: "",
Username: "",
Password: "",
DB: 0,
}
redisCache := rediscache.NewRedisCache(
expire,
redisCacheOptions)
}
```
```go
package service
import (
"context"
"github.com/ercantopuz/rediscache"
)
type service struct {
redisCache rediscache.Cache
}
func (s *service) GetData() {
var err error
var expectedData model.Data{}
expectedData, err = s.redisCache.Get(
context.Background(),
key,
expectedData)
/****/
err = s.redisCache.Set(
context.Background(),
key,
dataFromRepository)
}
```