Skip to content

loon-hejw/gorm-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gorm-cache aims to provide a look-aside, almost-no-code-modification cache solution for gorm users.

gorm-cache 旨在为gorm用户提供一个即插即用的旁路缓存解决方案。

package main

import (
	"context"

	"github.com/loon-hejw/gorm-cache/cache"
	"gorm.io/gorm"
)

func main() {

	var dial gorm.Dialector

	// plugin = NewCachePlugin(cfg.Prefix, cache.Session())
	gdb, err := gorm.Open(dial, &gorm.Config{})
	if err != nil {
		panic(err)
	}

	gdb.Use(NewCachePlugin("my-plugin", cache.Session()))

	ctx := context.Background()

	// use cache
	_ = gdb.Session(&gorm.Session{Context: ctx})

	// non use cache
	_ = gdb.Session(&gorm.Session{Context: NonuseCache(ctx)})
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages