mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-18 18:39:42 +00:00
31 lines
519 B
Go
31 lines
519 B
Go
package cache
|
|
|
|
import (
|
|
"github.com/OrlovEvgeny/go-mcache"
|
|
"time"
|
|
)
|
|
|
|
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)
|
|
}
|
|
|
|
func NewInMemoryCache() ICache {
|
|
return &MCache{mcache.New()}
|
|
}
|