mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-28 02:41:57 +08:00
Feat: cache in-memory store
This commit is contained in:
26
pkg/cache/memo.go
vendored
Normal file
26
pkg/cache/memo.go
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package cache
|
||||
|
||||
import "sync"
|
||||
|
||||
// MemoStore 内存存储驱动
|
||||
type MemoStore struct {
|
||||
Store *sync.Map
|
||||
}
|
||||
|
||||
// NewMemoStore 新建内存存储
|
||||
func NewMemoStore() *MemoStore {
|
||||
return &MemoStore{
|
||||
Store: &sync.Map{},
|
||||
}
|
||||
}
|
||||
|
||||
// Set 存储值
|
||||
func (store *MemoStore) Set(key string, value interface{}) error {
|
||||
store.Store.Store(key, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get 取值
|
||||
func (store *MemoStore) Get(key string) (interface{}, bool) {
|
||||
return store.Store.Load(key)
|
||||
}
|
||||
Reference in New Issue
Block a user