Skip to content

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

Notifications You must be signed in to change notification settings

44437/rediscache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published