1234567891011121314151617181920212223242526272829303132 |
- package cache
- import (
- "fmt"
- "time"
- "github.com/patrickmn/go-cache"
- )
- type Cache struct {
- C *cache.Cache
- }
- func (c *Cache) getCache(myId string) (interface{}, bool) {
- return c.C.Get(myId)
- }
- func (c *Cache) setCache(myId string, myVal interface{}) {
- c.C.Set(myId, myVal, 3*time.Hour)
- }
- func (c *Cache) setCacheTimeout(myId string, myVal interface{}, timeout int64) {
- c.C.Set(myId, myVal, time.Duration(timeout)*time.Second)
- }
- func (c *Cache) setToken(userId int, token string) {
- c.C.Set(fmt.Sprintf("token_%d", userId), token, 3*time.Hour)
- }
- func (c *Cache) delCache(myId string) {
- c.C.Delete(myId)
- }
|