mirror of
https://github.com/usememos/memos.git
synced 2024-11-16 03:34:33 +08:00
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"github.com/usememos/memos/server/profile"
|
|
)
|
|
|
|
// Store provides database access to all raw objects.
|
|
type Store struct {
|
|
Profile *profile.Profile
|
|
driver Driver
|
|
workspaceSettingCache sync.Map // map[string]*storepb.WorkspaceSetting
|
|
userCache sync.Map // map[int]*User
|
|
userSettingCache sync.Map // map[string]*UserSetting
|
|
idpCache sync.Map // map[int]*IdentityProvider
|
|
idpV1Cache sync.Map // map[int]*storepb.IdentityProvider
|
|
}
|
|
|
|
// New creates a new instance of Store.
|
|
func New(driver Driver, profile *profile.Profile) *Store {
|
|
return &Store{
|
|
driver: driver,
|
|
Profile: profile,
|
|
}
|
|
}
|
|
|
|
func (s *Store) MigrateManually(ctx context.Context) error {
|
|
if err := s.MigrateWorkspaceSetting(ctx); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *Store) Vacuum(ctx context.Context) error {
|
|
return s.driver.Vacuum(ctx)
|
|
}
|
|
|
|
func (s *Store) Close() error {
|
|
return s.driver.Close()
|
|
}
|
|
|
|
func (s *Store) GetCurrentDBSize(ctx context.Context) (int64, error) {
|
|
return s.driver.GetCurrentDBSize(ctx)
|
|
}
|