Revert "Add get-or-create-store"

This reverts commit 7ffd769240.
This commit is contained in:
Tony
2024-10-03 13:53:59 +08:00
parent 7ffd769240
commit 3acf66ee57
7 changed files with 3 additions and 96 deletions
+3 -30
View File
@@ -42,17 +42,6 @@ export async function getStore(path: string): Promise<Store | undefined> {
return await Store.getStore(path)
}
/**
* @param path: Path to save the store in `app_data_dir`
* @param options: Store configuration options
*/
export async function getOrCreateStore(
path: string,
options?: StoreOptions
): Promise<Store> {
return await Store.getOrCreateStore(path, options)
}
/**
* A lazy loaded key-value store persisted by the backend layer.
*
@@ -67,7 +56,9 @@ export class LazyStore implements IStore {
private get store(): Promise<Store> {
if (!this._store) {
this._store = getOrCreateStore(this.path, this.options)
this._store = createStore(this.path, this.options).catch(
async () => (await getStore(this.path))!
)
}
return this._store
}
@@ -183,24 +174,6 @@ export class Store extends Resource implements IStore {
return resourceId ? new Store(resourceId, path) : undefined
}
/**
* @param path: Path to save the store in `app_data_dir`
* @param options: Store configuration options
*/
static async getOrCreateStore(
path: string,
options?: StoreOptions
): Promise<Store> {
const resourceId = await invoke<number>(
'plugin:store|get_or_create_store',
{
path,
...options
}
)
return new Store(resourceId, path)
}
async set(key: string, value: unknown): Promise<void> {
await invoke('plugin:store|set', {
rid: this.rid,