lib/app/contact-cache.go

26 lines
427 B
Go
Raw Normal View History

2021-01-27 23:11:19 +00:00
package app
import "sync"
var contactCache = contactCacheType{
obj: map[string]*Contact{},
}
type contactCacheType struct {
sync.RWMutex
obj map[string]*Contact
}
func (m *contactCacheType) get(recordID string) (*Contact, bool) {
m.RLock()
defer m.RUnlock()
r, ok := m.obj[recordID]
return r, ok
}
func (m *contactCacheType) put(recordID string, itm *Contact) {
m.Lock()
defer m.Unlock()
m.obj[recordID] = itm
}