File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 88
99type MemoryService struct {
1010 Slots map [string ]interface {}
11+ mu sync.Mutex
1112}
1213
1314func NewMemoryService () * MemoryService {
@@ -27,20 +28,19 @@ func (s *MemoryService) NewStore(id string, subIDs ...string) Store {
2728type MemoryStore struct {
2829 Key string
2930 memory * MemoryService
30- mu sync.Mutex
3131}
3232
3333func (store * MemoryStore ) Save (val interface {}) error {
34- store .mu .Lock ()
35- defer store .mu .Unlock ()
34+ store .memory . mu .Lock ()
35+ defer store .memory . mu .Unlock ()
3636
3737 store .memory .Slots [store .Key ] = val
3838 return nil
3939}
4040
4141func (store * MemoryStore ) Load (val interface {}) error {
42- store .mu .Lock ()
43- defer store .mu .Unlock ()
42+ store .memory . mu .Lock ()
43+ defer store .memory . mu .Unlock ()
4444
4545 v := reflect .ValueOf (val )
4646 if data , ok := store .memory .Slots [store .Key ]; ok {
@@ -54,8 +54,8 @@ func (store *MemoryStore) Load(val interface{}) error {
5454}
5555
5656func (store * MemoryStore ) Reset () error {
57- store .mu .Lock ()
58- defer store .mu .Unlock ()
57+ store .memory . mu .Lock ()
58+ defer store .memory . mu .Unlock ()
5959
6060 delete (store .memory .Slots , store .Key )
6161 return nil
You can’t perform that action at this time.
0 commit comments