コード例 #1
0
ファイル: mem.go プロジェクト: choirudin2210/go-in-5-minutes
// Get is the interface implementation. Returns ErrNotFound if no such key existed. Callers should pass a pointer to a model so that Get can write the fetched model into it
func (m *Mem) Get(key models.Key, model models.Model) error {
	m.mut.RLock()
	defer m.mut.RUnlock()
	md, ok := m.m[key.String()]
	if !ok {
		return ErrNotFound
	}
	return model.Set(md)
}