store.go 897 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. workspaceSettingCache sync.Map // map[string]*storepb.WorkspaceSetting
  12. userCache sync.Map // map[int]*User
  13. userSettingCache sync.Map // map[string]*storepb.UserSetting
  14. idpCache sync.Map // map[int]*storepb.IdentityProvider
  15. }
  16. // New creates a new instance of Store.
  17. func New(driver Driver, profile *profile.Profile) *Store {
  18. return &Store{
  19. driver: driver,
  20. Profile: profile,
  21. }
  22. }
  23. func (*Store) MigrateManually(context.Context) error {
  24. return nil
  25. }
  26. func (s *Store) Close() error {
  27. return s.driver.Close()
  28. }
  29. func (s *Store) GetCurrentDBSize(ctx context.Context) (int64, error) {
  30. return s.driver.GetCurrentDBSize(ctx)
  31. }