package memory import ( "sync" "git.andreafazzi.eu/andrea/probo/hasher" "git.andreafazzi.eu/andrea/probo/models" "git.andreafazzi.eu/andrea/probo/store" ) type Store[T Storable] struct { ids map[string]T hashes map[string]T // A mutex is used to synchronize read/write access to the map lock sync.RWMutex } func NewStore[T store.Storable]() *Store[T] { store := new(Store[T]) store.ids = make(map[string]T) return store } type QuizStore struct { *Store[*Quiz] questions *Store[*Question] answers *Store[*Answer] } func NewMemoryProboCollectorStore(hasher hasher.Hasher) *MemoryProboCollectorStore { s := new(MemoryProboCollectorStore) s.hasher = hasher s.questionsHashes = make(map[string]*models.Question) s.answersHashes = make(map[string]*models.Answer) s.quizzesHashes = make(map[string]*models.Quiz) s.quizzes = make(map[string]*models.Quiz) s.collections = make(map[string]*models.Collection) s.participants = make(map[string]*models.Participant) return s }