Skip to content

Commit

Permalink
fix: run compaction every interval (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
CircuitCoder authored Dec 17, 2024
1 parent 059c3b4 commit 99a1b6b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
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

0 comments on commit 99a1b6b

Please sign in to comment.