Former-commit-id: bcb8905faf20e08be1ef9ec203385a1a7440eebd
This commit is contained in:
Gerasimos Maropoulos 2018-05-09 01:28:26 +03:00
parent 0fc4436da6
commit 4d9909cba5

View File

@ -62,7 +62,11 @@ func (s *mem) Set(sid string, lifetime LifeTime, key string, value interface{},
} }
func (s *mem) Get(sid string, key string) interface{} { func (s *mem) Get(sid string, key string) interface{} {
return s.values[sid].Get(key) s.mu.RLock()
v := s.values[sid].Get(key)
s.mu.RUnlock()
return v
} }
func (s *mem) Visit(sid string, cb func(key string, value interface{})) { func (s *mem) Visit(sid string, cb func(key string, value interface{})) {
@ -70,7 +74,11 @@ func (s *mem) Visit(sid string, cb func(key string, value interface{})) {
} }
func (s *mem) Len(sid string) int { func (s *mem) Len(sid string) int {
return s.values[sid].Len() s.mu.RLock()
n := s.values[sid].Len()
s.mu.RUnlock()
return n
} }
func (s *mem) Delete(sid string, key string) (deleted bool) { func (s *mem) Delete(sid string, key string) (deleted bool) {
@ -81,9 +89,9 @@ func (s *mem) Delete(sid string, key string) (deleted bool) {
} }
func (s *mem) Clear(sid string) { func (s *mem) Clear(sid string) {
s.mu.RLock() s.mu.Lock()
s.values[sid].Reset() s.values[sid].Reset()
s.mu.RUnlock() s.mu.Unlock()
} }
func (s *mem) Release(sid string) { func (s *mem) Release(sid string) {