continuing indexeddb work

This commit is contained in:
Jack Case
2025-12-06 22:02:02 +00:00
parent 298a797538
commit 54c2787da1

View File

@@ -50,17 +50,44 @@ class SlopDB {
return db_promise return db_promise
} }
start_transaction(storeNames: string | Array<string>, mode: IDBTransactionMode, options: IDBTransactionOptions = undefined): IDBTransaction {
return this.db.transaction(storeNames, mode, options)
}
} }
class CheckCache { class CheckCache {
slopdb: SlopDB slopdb: SlopDB
cache_capacity: number
static cache_objectstore_name = "checkcache"
constructor(slopdb: SlopDB) { constructor(slopdb: SlopDB, max_entries: number) {
this.slopdb = slopdb this.slopdb = slopdb
this.cache_capacity = max_entries
} }
start_transaction(mode: IDBTransactionMode): IDBTransaction { cache_item_factory(url: URL) {
const transaction = this.slopdb.db.transaction("checkcache", mode) return {
return transaction url: url,
check_timestamp: Date.now()
}
}
async evict_least_recently_checked(count: number) {
const transaction = this.slopdb.start_transaction(CheckCache.cache_objectstore_name, "readwrite")
const cache_objectstore = transaction.objectStore(CheckCache.cache_objectstore_name)
const cursor_result_promise = new Promise((resolve, reject) => {
const cache_cursor_request = cache_objectstore.openCursor()
cache_cursor_request.onerror = (error) => {
reject(error)
}
cache_cursor_request.onsuccess = (event) => {
}
})
} }
} }