lib/app/account-cache.go

26 lines
427 B
Go

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