lib/app/company-cache.go

30 lines
526 B
Go
Raw Normal View History

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