Skip to content

Commit

Permalink
move storage init closer to caller
Browse files Browse the repository at this point in the history
  • Loading branch information
da440dil committed Aug 6, 2019
1 parent dfb2e03 commit f09c888
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func newStorage() *storage {
return s
}

func (s *storage) init() {
s.mutex.Lock()
s.items = make(map[string]*item)
s.mutex.Unlock()
}

func (s *storage) Incr(key string, ttl int) (int, int, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
Expand Down Expand Up @@ -84,12 +90,6 @@ func (s *storage) get(key string) *item {
return nil
}

func (s *storage) init() {
s.mutex.Lock()
s.items = make(map[string]*item)
s.mutex.Unlock()
}

func durationToMilliseconds(duration time.Duration) int {
return int(duration / time.Millisecond)
}
Expand Down

0 comments on commit f09c888

Please sign in to comment.