feat: add HashMap store

This commit is contained in:
Cheliangzhao 2024-04-22 16:25:22 +08:00
parent 7b05105d4e
commit 71f544c0be

View File

@ -0,0 +1,38 @@
import { ICombStoreCore, StoreValueType } from './StoreCoreType';
import { HashMap } from '@kit.ArkTS';
export default class HashMapStoreCore implements ICombStoreCore {
private readonly TAG: string = 'HashMapStoreCore'
private store: HashMap<string, StoreValueType>
constructor() {
this.store = new HashMap()
}
async set(key: string, value: StoreValueType): Promise<StoreValueType> {
this.store.set(key, value)
return value
}
get(key: string, defaultValue: StoreValueType): Promise<StoreValueType> {
throw new Error('Method not implemented.');
}
getSync(key: string, defaultValue: StoreValueType): StoreValueType {
return this.store.get(key) ?? defaultValue
}
async remove(key: string): Promise<void> {
this.store.remove(key)
}
async reset(): Promise<void> {
this.store.clear()
}
async flush(): Promise<void> {
}
async init(): Promise<void> {
}
}