lib/app/company-cache.go

28 lines
432 B
Go
Raw Permalink Normal View History

2021-01-28 18:05:25 +00:00
package app
import (
"sync"
)
var companyCache = companyCacheType{
2021-01-28 20:00:21 +00:00
obj: map[string]*Company{},
2021-01-28 18:05:25 +00:00
}
type companyCacheType struct {
sync.RWMutex
2021-01-28 20:00:21 +00:00
obj map[string]*Company
2021-01-28 18:05:25 +00:00
}
2021-01-28 20:00:21 +00:00
func (m *companyCacheType) get(recordID string) (*Company, bool) {
2021-01-28 18:05:25 +00:00
m.RLock()
defer m.RUnlock()
r, ok := m.obj[recordID]
return r, ok
}
2021-01-28 20:00:21 +00:00
func (m *companyCacheType) put(recordID string, itm *Company) {
2021-01-28 18:05:25 +00:00
m.Lock()
defer m.Unlock()
m.obj[recordID] = itm
}