Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace cache #632

Merged
merged 4 commits into from
Aug 20, 2024
Merged

workspace cache #632

merged 4 commits into from
Aug 20, 2024

Conversation

pelikhan
Copy link
Member

Simple KV store to implement cheap memories in scripts


```js
const cache = await workspace.cache("summary")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect use of 'await' outside of an async function.

generated by pr-docs-review-commit await_usage

const cache = await workspace.cache("summary")
// write entries
await cache.set("file.txt", "...")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect use of 'await' outside of an async function.

generated by pr-docs-review-commit await_usage

await cache.set("file.txt", "...")
// read entries
const content = await cache.get("file.txt")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect use of 'await' outside of an async function.

generated by pr-docs-review-commit await_usage

values: async () =>
res.entries().then((es) => es.map((e) => e.val)),
}
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no error handling for the JSONLineCache.byName<any, any>(name) function call. If this function fails, it could lead to unexpected behavior. Consider adding error handling to improve the robustness of your code. 😊

generated by pr-review-commit missing_error_handling

@@ -105,6 +104,7 @@ export async function createPromptContext(
readJSON: (f) => runtimeHost.workspace.readJSON(f),
readXML: (f) => runtimeHost.workspace.readXML(f),
writeText: (f, c) => runtimeHost.workspace.writeText(f, c),
cache: (n) => runtimeHost.workspace.cache(n),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtimeHost.workspace.cache(n) function call lacks error handling. If this function fails, it could lead to unexpected behavior. It's a good practice to handle potential errors to make your code more reliable. 😊

generated by pr-review-commit missing_error_handling

*/
cache<K = any, V = any>(
cacheName: string
): Promise<WorkspaceFileCache<K, V>>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache<K = any, V = any>(cacheName: string) function does not validate the types of its parameters. This could lead to unexpected behavior if the function is called with incorrect types. Consider adding type validation to improve the robustness of your code. 😊

generated by pr-review-commit missing_type_validation

@pelikhan pelikhan merged commit 0a5e182 into main Aug 20, 2024
10 checks passed
@pelikhan pelikhan deleted the workspacecache branch August 20, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant