perf improvement for db cleanup

This commit is contained in:
Nolan Lawson 2018-01-19 21:51:22 -08:00
parent 0dbfbcf0f2
commit 9bb9632913
2 changed files with 4 additions and 1 deletions

View file

@ -14,6 +14,9 @@ async function cleanup(instanceName, timeline) {
store.count().onsuccess = (e) => { store.count().onsuccess = (e) => {
let count = e.target.result let count = e.target.result
if (count <= MAX_NUM_STORED_STATUSES) {
return
}
let openKeyCursor = index.openKeyCursor || index.openCursor let openKeyCursor = index.openKeyCursor || index.openCursor
openKeyCursor.call(index, null, 'prev').onsuccess = (e) => { openKeyCursor.call(index, null, 'prev').onsuccess = (e) => {
let cursor = e.target.result let cursor = e.target.result

View file

@ -1,5 +1,5 @@
import { cleanupOldStatuses } from './cleanup' import { cleanupOldStatuses } from './cleanup'
import { OBJECT_STORE, getDatabase, doTransaction } from './shared' import { OBJECT_STORE, getDatabase } from './shared'
import { toReversePaddedBigInt, transformStatusForStorage } from './utils' import { toReversePaddedBigInt, transformStatusForStorage } from './utils'
export async function getTimeline(instanceName, timeline, maxId = null, limit = 20) { export async function getTimeline(instanceName, timeline, maxId = null, limit = 20) {