package app import ( "sync" ) var companyCache = companyCacheType{ obj: map[string]*Company{}, } type companyCacheType struct { sync.RWMutex obj map[string]*Company } func (m *companyCacheType) get(recordID string) (*Company, bool) { m.RLock() defer m.RUnlock() r, ok := m.obj[recordID] return r, ok } func (m *companyCacheType) put(recordID string, itm *Company) { m.Lock() defer m.Unlock() m.obj[recordID] = itm }