Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 7 days 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 (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-05-07T07:37:34.000Z (over 2 years ago)
- Last Synced: 2024-07-24T18:56:45.716Z (4 months ago)
- Topics: go, golang, redis, redis-cache, redis-client, redis-database, redis-server
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rediscache
[![Pipeline](https://github.com/ercantopuz/rediscache/actions/workflows/ci.yaml/badge.svg)](https://github.com/ercantopuz/rediscache/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/ercantopuz/rediscache/branch/master/graph/badge.svg?token=DV0KA0K3X8)](https://codecov.io/gh/ercantopuz/rediscache)
[![Release](https://img.shields.io/github/release/ercantopuz/rediscache.svg?style=flat-square)](https://github.com/ercantopuz/rediscache/releases)
[![Go Report Card](https://goreportcard.com/badge/github.com/ercantopuz/rediscache)](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 mainimport "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 serviceimport (
"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)
}
```