Skip to content

Latest commit

 

History

History
70 lines (54 loc) · 1.59 KB

README.md

File metadata and controls

70 lines (54 loc) · 1.59 KB

rediscache

Pipeline codecov Release Go Report Card

Installation

This package makes it easy to abstract your Redis connection and use Get and Set methods.

go get github.com/ercantopuz/rediscache

Import it in your code:

import "github.com/ercantopuz/rediscache"

Quick start

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)
}
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)
}