mirror of
https://github.com/cloudreve/Cloudreve.git
synced 2026-11-17 22:58:07 +00:00
Feat: cache in-memory store
This commit is contained in:
1 parent
5d50e7ed1e
commit
7375cc01f1
8 files changed
+134
-26
No files matched your search
Vendored
+26
@@ -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