Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run compaction every dbclean interval #834

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/models/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Users {
});

db.ensureIndex({fieldName: 'username', unique: true});
db.setAutocompactionInterval(config.dbCleanInterval);

return db;
})();
Expand Down
1 change: 1 addition & 0 deletions server/services/feedService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FeedService extends BaseService<Record<string, never>> {

constructor(...args: ConstructorParameters<typeof BaseService>) {
super(...args);
this.db.setAutocompactionInterval(config.dbCleanInterval);

this.onServicesUpdated = async () => {
// Execute once only.
Expand Down
1 change: 1 addition & 0 deletions server/services/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NotificationService extends BaseService<NotificationServiceEvents> {

constructor(...args: ConstructorParameters<typeof BaseService>) {
super(...args);
this.db.setAutocompactionInterval(config.dbCleanInterval);

(async () => {
const notifications = await this.db.findAsync<Notification>({}).catch(() => undefined);
Expand Down
5 changes: 5 additions & 0 deletions server/services/settingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class SettingService extends BaseService<SettingServiceEvents> {
filename: path.join(config.dbPath, this.user._id, 'settings', 'settings.db'),
});

constructor(...args: ConstructorParameters<typeof BaseService>) {
super(...args);
this.db.setAutocompactionInterval(config.dbCleanInterval);
}

async destroy(drop: boolean) {
if (drop) {
await this.db.dropDatabaseAsync();
Expand Down
Loading