33 lines
520 B
Go
Raw Permalink Normal View History

2021-12-03 04:15:48 +01:00
package cache
import (
"time"
2024-04-02 21:14:03 +02:00
"github.com/OrlovEvgeny/go-mcache"
)
type MCache struct {
mcache *mcache.CacheDriver
}
func (m *MCache) Set(key string, value []byte, ttl time.Duration) error {
return m.mcache.Set(key, value, ttl)
}
func (m *MCache) Get(key string) ([]byte, bool) {
val, ok := m.mcache.Get(key)
if ok {
return val.([]byte), true
} else {
return nil, false
}
}
func (m *MCache) Remove(key string) {
m.mcache.Remove(key)
}
2021-12-03 04:15:48 +01:00
func NewInMemoryCache() ICache {
return &MCache{mcache.New()}
2021-12-03 04:15:48 +01:00
}