Skip to content

Latest commit

 

History

History

redis

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Cachego - Redis driver

The drivers uses go-redis to store the cache data.

Usage

package main

import (
	"log"
	"time"

	rd "github.com/redis/go-redis/v9"

	"github.com/faabiosr/cachego/redis"
)

func main() {
	cache := redis.New(
		rd.NewClient(&rd.Options{
			Addr: ":6379",
		}),
	)

	if err := cache.Save("user_id", "1", 10*time.Second); err != nil {
		log.Fatal(err)
	}

	id, err := cache.Fetch("user_id")
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("user id: %s \n", id)
}