Files
alfred-be/alfred/pkg/cache/cache.go
2026-03-08 16:14:42 +05:30

27 lines
658 B
Go

package cache
import (
"alfred/pkg/log"
"alfred/utils"
"fmt"
"time"
)
func (c *Client) PutWithTtl(key string, value interface{}, time time.Duration) {
c.cacheClient.Set(key, value, time)
}
func (c *Client) PutWithDefaultTtl(key string, value interface{}) {
log.Info(fmt.Sprintf("set %s value corresponding to %s key in cache with default ttl", value, key))
c.cacheClient.Set(key, value, utils.DefaultCacheTtl)
}
func (c *Client) Get(key string) (interface{}, bool) {
//c.logger.Info(fmt.Sprintf("get value corresponding to %s from cache", key))
return c.cacheClient.Get(key)
}
func (c *Client) Delete(key string) {
c.cacheClient.Delete(key)
}