mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-05-14 17:27:10 +02:00
Add redis for caching, first try during a train ride so expect it to not be working yet
This commit is contained in:
parent
b8b9886ee1
commit
5b6eecc75f
12 changed files with 149 additions and 32 deletions
28
server/cache/memory.go
vendored
28
server/cache/memory.go
vendored
|
@ -1,7 +1,31 @@
|
|||
package cache
|
||||
|
||||
import "github.com/OrlovEvgeny/go-mcache"
|
||||
import (
|
||||
"github.com/OrlovEvgeny/go-mcache"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MCache struct {
|
||||
mcache *mcache.CacheDriver
|
||||
}
|
||||
|
||||
func (m *MCache) Set(key string, value string, ttl time.Duration) error {
|
||||
return m.mcache.Set(key, value, ttl)
|
||||
}
|
||||
|
||||
func (m *MCache) Get(key string) (string, bool) {
|
||||
val, ok := m.mcache.Get(key)
|
||||
if ok {
|
||||
return val.(string), true
|
||||
} else {
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MCache) Remove(key string) {
|
||||
m.mcache.Remove(key)
|
||||
}
|
||||
|
||||
func NewInMemoryCache() ICache {
|
||||
return mcache.New()
|
||||
return &MCache{mcache.New()}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue