@beoe/cache
v0.0.1
Published
Shareable persistent LRU TTL cache based on SQLite
Downloads
106
Readme
@beoe/cache
[!WARNING] One of ideas was to use this as shared cache inside Astro components. But for now it doesn't work. If it is used inside Astro component build process (prerendering) fails. Though it does work in rehype/remark plugins. And in Astro components in development mode.
Probably would need to create custom Astro integration (virtual module), but hard to tell because I don't understand why it fails
Thin wrapper arround @beoe/sqlitecache so the same cache can be shared between different rehype/remark plugins and Astro components
Because cache would be "hidden" inside other packages it exposes way to configure instance through local file (with cosmiconfig).
By default it stores cache in node_modules/.beoe
folder. This will make it easy to use, node_modules
often cached in CI and added to .gitignore
. On the other hand I haven't seen this approach before, there can be downsides that I haven't thought about.
You can change where cache is stored using configuration (beoe.config.mjs
):
import { defineConfig } from "@beoe/cache";
export default defineConfig({
database: "other_folder/cache.sqlite",
});
Usage
import { getCache } from "@beoe/cache";
const cache = await getCache();
TODO
- tests
- write documentation about configuration options