memos/store/store.go
Steven 4c1d1c70d1 refactor: rename workspace to instance throughout codebase
Remove work-related terminology by renaming "workspace" to "instance"
across the entire application. This change better reflects that Memos
is a self-hosted tool suitable for personal and non-work use cases.

Breaking Changes:
- API endpoints: /api/v1/workspace/* → /api/v1/instance/*
- gRPC service: WorkspaceService → InstanceService
- Proto types: WorkspaceSetting → InstanceSetting
- Frontend translation keys: workspace-section → instance-section

Backend Changes:
- Renamed proto definitions and regenerated code
- Updated all store layer methods and database drivers
- Renamed service implementations and API handlers
- Updated cache from workspaceSettingCache to instanceSettingCache

Frontend Changes:
- Renamed service client: workspaceServiceClient → instanceServiceClient
- Updated all React components and state management
- Refactored stores: workspace.ts → instance.ts
- Updated all 32 locale translation files

All tests pass and both backend and frontend build successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 23:35:35 +08:00

57 lines
1.3 KiB
Go

package store
import (
"time"
"github.com/usememos/memos/internal/profile"
"github.com/usememos/memos/store/cache"
)
// Store provides database access to all raw objects.
type Store struct {
profile *profile.Profile
driver Driver
// Cache settings
cacheConfig cache.Config
// Caches
instanceSettingCache *cache.Cache // cache for instance settings
userCache *cache.Cache // cache for users
userSettingCache *cache.Cache // cache for user settings
}
// New creates a new instance of Store.
func New(driver Driver, profile *profile.Profile) *Store {
// Default cache settings
cacheConfig := cache.Config{
DefaultTTL: 10 * time.Minute,
CleanupInterval: 5 * time.Minute,
MaxItems: 1000,
OnEviction: nil,
}
store := &Store{
driver: driver,
profile: profile,
cacheConfig: cacheConfig,
instanceSettingCache: cache.New(cacheConfig),
userCache: cache.New(cacheConfig),
userSettingCache: cache.New(cacheConfig),
}
return store
}
func (s *Store) GetDriver() Driver {
return s.driver
}
func (s *Store) Close() error {
// Stop all cache cleanup goroutines
s.instanceSettingCache.Close()
s.userCache.Close()
s.userSettingCache.Close()
return s.driver.Close()
}