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