Skip to content

Some performance changes in utils and caching - #35

Merged
whomwah merged 5 commits into
mainfrom
feat/cache-prep
Jan 12, 2026
Merged

whomwah merged 5 commits into
mainfrom
feat/cache-prep

Conversation

@whomwah

@whomwah whomwah commented Jan 12, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a prepared statement cache for SQLite queries in the cache.ts helper, improving performance and resource management by reusing prepared statements and cleaning them up properly. It also adds comprehensive tests for cache functionality, updates documentation and developer commands to use just, and expands the permissions for running tests.

Prepared statement caching and cache improvements:

  • Added a statementCache using a WeakMap to cache prepared SQLite statements by database and column, with helper functions getCachedStatement and cleanupStatementCache to manage statement lifecycle and prevent memory leaks. The requestFromCache function now uses this cache for improved efficiency. [1] [2]
  • Exposed cache internals (statementCache, getCachedStatement) for testing purposes.

Testing enhancements:

  • Added a new test suite cache.test.ts that thoroughly tests statement caching, cache cleanup, and all cache operations including updateCache, deleteCache, cleanCache, and requestFromCache.

Developer workflow and documentation:

  • Updated the justfile and documentation (AGENTS.md) to use just for all developer commands, replacing direct deno calls and adding new recipes for common tasks. [1] [2]
  • Expanded the permissions granted to deno test in CI and local runs to include --allow-read, --allow-write, --allow-ffi, and --allow-net for broader test coverage. [1] [2] [3]

Utility function improvement:

  • Refactored the uniq function in utils.ts to use a Set for more efficient duplicate removal based on the uid property.

Update test commands in justfile, AGENTS.md, and CI workflow to use
--allow-env --allow-read --allow-write --allow-ffi --allow-net for Deno
tests. This ensures tests have necessary permissions for all features.
@whomwah whomwah self-assigned this Jan 12, 2026
conditions

Clean stale cache entries for a specific endpoint using base URL pattern
matching. This prevents race conditions when multiple endpoints are
fetched in parallel. Remove noisy console warnings from cache logic.
Improve logging in fetchNewDataFromAPIandStore.
@whomwah
whomwah merged commit 4fd7e54 into main Jan 12, 2026
1 check passed
@whomwah
whomwah deleted the feat/cache-prep branch January 12, 2026 21:56
@whomwah

whomwah commented Jan 12, 2026

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant