olahol/melody

Session.Set, Session.Get isn't concurrent safe?

ianberdin opened this issue · 0 comments

 func (s *Session) Set(key string, value interface{}) {
   	if s.Keys == nil {
   		s.Keys = make(map[string]interface{})
  	 }
  	 s.Keys[key] = value
   }
  
   // Get returns the value for the given key, ie: (value, true).
   // If the value does not exists it returns (nil, false)
   func (s *Session) Get(key string) (value interface{}, exists bool) {
  	 if s.Keys != nil {
  		 value, exists = s.Keys[key]
  	 }
  	 return
  }

I think session must have concurrent safe map.
https://golang.org/pkg/sync/#Map
Or just locks.