mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 01:29:31 +08:00
feat(infra): opti indexer performance (#8557)
This commit is contained in:
@@ -50,7 +50,9 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
|
||||
async accept(): Promise<Job[] | null> {
|
||||
await this.ensureInitialized();
|
||||
const jobs = [];
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite');
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite', {
|
||||
durability: 'relaxed',
|
||||
});
|
||||
|
||||
// if no priority jobs
|
||||
|
||||
@@ -148,7 +150,9 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
|
||||
|
||||
async complete(jobs: Job[]): Promise<void> {
|
||||
await this.ensureInitialized();
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite');
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite', {
|
||||
durability: 'relaxed',
|
||||
});
|
||||
|
||||
for (const { id } of jobs) {
|
||||
await trx
|
||||
@@ -162,7 +166,9 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
|
||||
|
||||
async return(jobs: Job[], retry: boolean = false): Promise<void> {
|
||||
await this.ensureInitialized();
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite');
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite', {
|
||||
durability: 'relaxed',
|
||||
});
|
||||
|
||||
for (const { id } of jobs) {
|
||||
if (retry) {
|
||||
@@ -185,7 +191,9 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
|
||||
|
||||
async clear(): Promise<void> {
|
||||
await this.ensureInitialized();
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite');
|
||||
const trx = this.database.transaction(['jobs'], 'readwrite', {
|
||||
durability: 'relaxed',
|
||||
});
|
||||
await trx.objectStore('jobs').clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user