forked from ubiquity-os/ubiquity-os-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ubiquity-os#167 from gentlementlegen/fix/disable-kv
- Loading branch information
Showing
6 changed files
with
115 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* KvStore is an interface representing a simple key-value store. | ||
* | ||
* @template T - The type of the value to be stored and retrieved. | ||
*/ | ||
export interface KvStore<T> { | ||
get(id: string): Promise<T | null>; | ||
put(id: string, state: T): Promise<void>; | ||
} | ||
|
||
/** | ||
* CloudflareKv is a class that provides an interface to interact with | ||
* Cloudflare KV (Key-Value) storage. | ||
* | ||
* It implements the KvStore interface to handle generic types. | ||
* | ||
* @template T - The type of the values being stored. | ||
*/ | ||
// export class CloudflareKv<T> implements KvStore<T> { | ||
// private _kv: KVNamespace; | ||
// | ||
// constructor(kv: KVNamespace) { | ||
// this._kv = kv; | ||
// } | ||
// | ||
// get(id: string): Promise<T | null> { | ||
// return this._kv.get(id, "json"); | ||
// } | ||
// | ||
// put(id: string, state: T): Promise<void> { | ||
// return this._kv.put(id, JSON.stringify(state)); | ||
// } | ||
// } | ||
|
||
/** | ||
* A class that implements the KvStore interface, representing an empty key-value store. | ||
* All get operations return null and put operations do nothing, but log the action. | ||
* | ||
* @template T - The type of values to be stored. | ||
*/ | ||
export class EmptyStore<T> implements KvStore<T> { | ||
constructor(kv: KVNamespace) { | ||
console.log(`Creating empty kv`, kv); | ||
} | ||
|
||
get(id: string): Promise<T | null> { | ||
console.log(`get KV ${id}`); | ||
return Promise.resolve(null); | ||
} | ||
|
||
put(id: string, state: T): Promise<void> { | ||
console.log(`put KV ${id} ${state}`); | ||
return Promise.resolve(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters