Run go get github.com/Ankush-Hegde/goCacheStore
from command line.
import (
Cache "github.com/Ankush-Hegde/goCacheStore"
)
DbEndpoint := UN:PASS@tcp(<IP>:<PORT>)/<DB>?parseTime=true&loc=Local
SessionLifetimeInSec := 1598453
_, cacheErr := Cache.MySQL(DbEndpoint, "tablename", "/", SessionLifetimeInSec, []byte("<SecretKey>"))
if cacheErr != nil {
return cacheErr
}
if cacheErr != nil {
defer Cache.DatabaseCacheStore.Close()
}
CacheFilePath := filepath.Join("path", "to_store_file")
SessionLifetimeInSec := 1598453
Cache.File(CacheFilePath, "/", SessionLifetimeInSec, []byte("<SecretKey>"))
Cache.CacheStorage.New(key, data, time)
data := Cache.CacheStorage.Get(key)
Cache.CacheStorage.Forget(key)
key must be unique string,
data must be the map[string]interface{},
time must be in sec(int),
https://pkg.go.dev/github.com/Ankush-Hegde/goCacheStore