Add idb-keyval backed archival storage (#9754)

* Add idb-keyval backed archival storage

* Cleanup

* Remove test
This commit is contained in:
Eric Bailey
2026-01-26 13:39:12 -06:00
committed by GitHub
parent 2ad84d7dfc
commit f26ac583e6
8 changed files with 157 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
import {MMKV} from '@bsky.app/react-native-mmkv'
import {type DB} from '#/storage/archive/db/types'
export function create({id}: {id: string}): DB {
const store = new MMKV({id})
return {
async get(key: string): Promise<string | undefined> {
return store.getString(key) ?? undefined
},
async set(key: string, value: string): Promise<void> {
store.set(key, value)
},
async delete(key: string): Promise<void> {
store.delete(key)
},
async clear(): Promise<void> {
store.clearAll()
},
}
}
+22
View File
@@ -0,0 +1,22 @@
import {clear, createStore, del, get, set} from 'idb-keyval'
import {type DB} from '#/storage/archive/db/types'
export function create({id}: {id: string}): DB {
const store = createStore(id, id)
return {
async get(key: string): Promise<string | undefined> {
return get(key, store) ?? undefined
},
async set(key: string, value: string): Promise<void> {
await set(key, value, store)
},
async delete(key: string): Promise<void> {
await del(key, store)
},
async clear(): Promise<void> {
await clear(store)
},
}
}
+6
View File
@@ -0,0 +1,6 @@
export type DB = {
get(key: string): Promise<string | undefined>
set(key: string, value: string): Promise<void>
delete(key: string): Promise<void>
clear(): Promise<void>
}