Files
graphql-monitoring-proxy/cache.go
T

30 lines
571 B
Go

package main
import (
"time"
fiber "github.com/gofiber/fiber/v2"
"github.com/gookit/goutil/strutil"
libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache"
)
func calculateHash(c *fiber.Ctx) string {
return strutil.Md5(c.Body())
}
func enableCache() {
cfg.Cache.CacheClient = libpack_cache.New(time.Duration(cfg.Cache.CacheTTL) * time.Second)
}
func cacheLookup(hash string) []byte {
obj, found := cfg.Cache.CacheClient.Get(hash)
if found {
return obj
}
return nil
}
func cacheDelete(hash string) {
cfg.Cache.CacheClient.Delete(hash)
}