lib/app/taxtype-cache.go

26 lines
427 B
Go
Raw Normal View History

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