memos/store/store.go

43 lines
981 B
Go
Raw Normal View History

2022-05-16 02:37:23 +03:00
package store
2022-05-21 19:59:22 +03:00
import (
2022-11-06 07:21:58 +03:00
"context"
"sync"
2022-06-27 17:09:06 +03:00
2023-09-17 17:55:13 +03:00
"github.com/usememos/memos/server/profile"
2022-05-21 19:59:22 +03:00
)
2022-08-24 16:53:12 +03:00
// Store provides database access to all raw objects.
2022-05-16 02:37:23 +03:00
type Store struct {
Profile *profile.Profile
driver Driver
systemSettingCache sync.Map // map[string]*SystemSetting
userCache sync.Map // map[int]*User
2023-06-29 17:55:03 +03:00
userSettingCache sync.Map // map[string]*UserSetting
2023-06-26 18:46:01 +03:00
idpCache sync.Map // map[int]*IdentityProvider
2022-05-16 02:37:23 +03:00
}
2022-08-24 16:53:12 +03:00
// New creates a new instance of Store.
func New(driver Driver, profile *profile.Profile) *Store {
2022-05-16 02:37:23 +03:00
return &Store{
Profile: profile,
driver: driver,
2022-05-16 02:37:23 +03:00
}
}
2022-11-06 07:21:58 +03:00
func (s *Store) BackupTo(ctx context.Context, filename string) error {
return s.driver.BackupTo(ctx, filename)
}
2022-11-06 07:21:58 +03:00
func (s *Store) Vacuum(ctx context.Context) error {
return s.driver.Vacuum(ctx)
2022-11-06 07:21:58 +03:00
}
func (s *Store) Close() error {
return s.driver.Close()
2022-11-06 07:21:58 +03:00
}
func (s *Store) GetCurrentDBSize(ctx context.Context) (int64, error) {
return s.driver.GetCurrentDBSize(ctx)
}