store.go 868 B

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