Create internal/thestore/event.Store and getter, setter

master
Bel LaPointe 2023-10-11 15:34:04 -06:00
parent 70841d7b14
commit caa0a8e0fa
2 changed files with 24 additions and 0 deletions

Binary file not shown.

View File

@ -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
}