Rename Simple mutex
// A Simple should not be copied.
type Simple struct {
m map[string][]byte
- l sync.Mutex
+ mu sync.Mutex
}
// NewSimple instantiates a new Simple snapstore and
@@ -25,8 +25,8 @@ func (s *Simple) Store(key string, val []byte) error {
buf := make([]byte, len(val))
_ = copy(buf, val)
- s.l.Lock()
- defer s.l.Unlock()
+ s.mu.Lock()
+ defer s.mu.Unlock()
s.m[key] = buf
@@ -35,8 +35,8 @@ func (s *Simple) Store(key string, val []byte) error {
// Load implements the Storer interface Load method
func (s *Simple) Load(key string) ([]byte, error) {
- s.l.Lock()
- defer s.l.Unlock()
+ s.mu.Lock()
+ defer s.mu.Unlock()
if buf, found := s.m[key]; found {
retBuf := make([]byte, len(buf))
@@ -50,16 +50,16 @@ func (s *Simple) Load(key string) ([]byte, error) {
// Delete implements the Storer interface Delete method
func (s *Simple) Delete(key string) {
- s.l.Lock()
- defer s.l.Unlock()
+ s.mu.Lock()
+ defer s.mu.Unlock()
delete(s.m, key)
}
// GetKeys implements the Storer interface GetKeys method
func (s *Simple) GetKeys() []string {
- s.l.Lock()
- defer s.l.Unlock()
+ s.mu.Lock()
+ defer s.mu.Unlock()
ret := make([]string, 0, len(s.m))
