26 lines
427 B
Go
26 lines
427 B
Go
|
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
|
||
|
}
|