store.go 760 B

123456789101112131415161718192021222324252627282930313233
  1. package store
  2. import (
  3. "sync"
  4. "github.com/usememos/memos/server/profile"
  5. )
  6. // Store provides database access to all raw objects.
  7. type Store struct {
  8. Profile *profile.Profile
  9. driver Driver
  10. workspaceSettingCache sync.Map // map[string]*storepb.WorkspaceSetting
  11. userCache sync.Map // map[int]*User
  12. userSettingCache sync.Map // map[string]*storepb.UserSetting
  13. idpCache sync.Map // map[int]*storepb.IdentityProvider
  14. }
  15. // New creates a new instance of Store.
  16. func New(driver Driver, profile *profile.Profile) *Store {
  17. return &Store{
  18. driver: driver,
  19. Profile: profile,
  20. }
  21. }
  22. func (s *Store) GetDriver() Driver {
  23. return s.driver
  24. }
  25. func (s *Store) Close() error {
  26. return s.driver.Close()
  27. }