Skip to content

Ankush-Hegde/goCacheStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goCacheStore

Installation

Run go get github.com/Ankush-Hegde/goCacheStore from command line.

Usage

import (
	Cache "github.com/Ankush-Hegde/goCacheStore"
)

for database cache storage

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

for filebased cache storage

CacheFilePath := filepath.Join("path", "to_store_file")
SessionLifetimeInSec := 1598453

Cache.File(CacheFilePath, "/", SessionLifetimeInSec, []byte("<SecretKey>"))

below is the code to create, get and forget the cache data,

Cache.CacheStorage.New(key, data, time)

data := Cache.CacheStorage.Get(key)

Cache.CacheStorage.Forget(key)

note:-

key must be unique string,
data must be the map[string]interface{},
time must be in sec(int),

link:-

https://pkg.go.dev/github.com/Ankush-Hegde/goCacheStore

About

file and DB based cache storage for golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages