Create internal/thestore/event.Store and getter, setter
parent
70841d7b14
commit
caa0a8e0fa
Binary file not shown.
|
|
@ -0,0 +1,24 @@
|
|||
package thestore
|
||||
|
||||
import "sync"
|
||||
|
||||
type Store sync.Map
|
||||
|
||||
func NewStore() *Store {
|
||||
s := sync.Map{}
|
||||
store := Store(s)
|
||||
return &store
|
||||
}
|
||||
|
||||
func (store *Store) Set(k string, v Event) {
|
||||
(*sync.Map)(store).Store(k, v)
|
||||
}
|
||||
|
||||
func (store *Store) Get(k string) (Event, bool) {
|
||||
got, ok := (*sync.Map)(store).Load(k)
|
||||
if !ok {
|
||||
return Event{}, false
|
||||
}
|
||||
event := got.(Event)
|
||||
return event, true
|
||||
}
|
||||
Loading…
Reference in New Issue