{"_id":"@alexmchan/memocache-store-sqlite","name":"@alexmchan/memocache-store-sqlite","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@alexmchan/memocache-store-sqlite","version":"2.0.0","private":false,"engines":{"node":">=24"},"dependencies":{"superjson":"^2.2.6","@alexmchan/memocache-common":"^2.0.0"},"devDependencies":{"@arethetypeswrong/cli":"^0.18.2","tsup":"^8.5.1","typescript":"^5.9.3","vite-tsconfig-paths":"^6.1.1","@vitest/coverage-v8":"^4.1.0","vitest":"^4.1.0","@alexmchan/memocache":"^2.0.0"},"repository":{"type":"git","url":"git+https://github.com/alexmchan/memocache.git"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"default":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"build":"tsup","check-exports":"pnpm pack --out ./ignore-package.tgz && pnpm exec attw ./ignore-package.tgz && rm ./ignore-package.tgz","typecheck":"tsc --noEmit","test":"vitest run","coverage":"vitest run --coverage","lint":"biome check .","lint:fix":"biome check --write .","test:watch":"vitest --watch"},"_id":"@alexmchan/memocache-store-sqlite@2.0.0","description":"A cache store backed by Node.js's standard-library [`node:sqlite`](https://nodejs.org/api/sqlite.html) module for [@alexmchan/memocache](https://github.com/alexmchan/memocache). **Zero external dependencies** — no native bindings to compile.","bugs":{"url":"https://github.com/alexmchan/memocache/issues"},"homepage":"https://github.com/alexmchan/memocache#readme","_integrity":"sha512-I1pdpVycDM0BJc3BM3ZZLUFs0PEgNJTZMuagW8IqTzsc6/1nxLtYGykn+qfE8ePJ0yHy81/z5vtLUCAly9CHuQ==","_resolved":"/private/var/folders/r7/v6yxz7l93hj4jz_lp08p8fbh0000gn/T/d4597003562aca1137b89948d7cadaa5/alexmchan-memocache-store-sqlite-2.0.0.tgz","_from":"file:alexmchan-memocache-store-sqlite-2.0.0.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-I1pdpVycDM0BJc3BM3ZZLUFs0PEgNJTZMuagW8IqTzsc6/1nxLtYGykn+qfE8ePJ0yHy81/z5vtLUCAly9CHuQ==","shasum":"f6215f2b2e150dfd00d2f767e1b7baa190ddea5f","tarball":"https://registry.npmjs.org/@alexmchan/memocache-store-sqlite/-/memocache-store-sqlite-2.0.0.tgz","fileCount":7,"unpackedSize":18759,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBt3j2pzLPgXyPaOKqkWTvQVQiNeoGENf4m2aiPbAE6WAiAb/atUC+dA10mvL52ilqtpJVLDbXq/+LvvRid/AveGJg=="}]},"_npmUser":{"name":"alexanderchan","email":"alexander.m.chan@gmail.com"},"directories":{},"maintainers":[{"name":"alexanderchan","email":"alexander.m.chan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/memocache-store-sqlite_2.0.0_1784073622210_0.3360411428102339"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-15T00:00:22.074Z","2.0.0":"2026-07-15T00:00:22.343Z","modified":"2026-07-15T00:00:22.598Z"},"maintainers":[{"name":"alexanderchan","email":"alexander.m.chan@gmail.com"}],"description":"A cache store backed by Node.js's standard-library [`node:sqlite`](https://nodejs.org/api/sqlite.html) module for [@alexmchan/memocache](https://github.com/alexmchan/memocache). **Zero external dependencies** — no native bindings to compile.","homepage":"https://github.com/alexmchan/memocache#readme","repository":{"type":"git","url":"git+https://github.com/alexmchan/memocache.git"},"bugs":{"url":"https://github.com/alexmchan/memocache/issues"},"readme":"## SQLite Store for Memocache\n\nA cache store backed by Node.js's standard-library [`node:sqlite`](https://nodejs.org/api/sqlite.html) module for [@alexmchan/memocache](https://github.com/alexmchan/memocache). **Zero external dependencies** — no native bindings to compile.\n\n> Migrating from `@alexmchan/memocache-store-libsql`? See [Migration](#migration-from-store-libsql) below.\n\n## Requirements\n\n- **Node.js >= 24.** `node:sqlite` ships in Node 24 (still marked experimental — importing it emits an `ExperimentalWarning`) and is stabilized in Node 26. Bun exposes `node:sqlite` compatibility as well.\n\n## Installation\n\n```bash\npnpm install @alexmchan/memocache-store-sqlite\n```\n\n## Usage\n\n```typescript\nimport { createCache } from '@alexmchan/memocache'\nimport { Time } from '@alexmchan/memocache-common'\nimport { createSqliteStore } from '@alexmchan/memocache-store-sqlite'\n\n// Open an in-memory database (default), or pass a file path to persist:\nconst sqliteStore = createSqliteStore({\n  location: ':memory:', // or './cache.db'\n  cleanupInterval: 5 * Time.Minute,\n  defaultTTL: 10 * Time.Minute,\n})\n\nconst cache = createCache({\n  stores: [sqliteStore],\n  defaultFresh: 1 * Time.Minute,\n  defaultTTL: 5 * Time.Minute,\n})\n\nconst { createCachedFunction } = cache\n\nconst cachedFunction = createCachedFunction(\n  async (id: string) => `Result for ${id}`,\n  { cachePrefix: '/results/by-id' },\n)\n\nconst result = await cachedFunction('example')\n```\n\nYou can also bring your own `DatabaseSync` instance:\n\n```typescript\nimport { DatabaseSync } from 'node:sqlite'\n\nconst database = new DatabaseSync('./cache.db')\nconst sqliteStore = createSqliteStore({ database })\n// An injected database is caller-owned: it is NOT closed when the store is disposed.\n```\n\n## Configuration Options\n\n- `database`: an existing `node:sqlite` `DatabaseSync` instance. If provided it is caller-owned and not closed on dispose.\n- `location`: path used to open a database when `database` is not provided. Defaults to `':memory:'`.\n- `tableName`: name of the table to create. Defaults to `cache`.\n- `defaultTTL`: default time-to-live for cache entries in milliseconds. Defaults to 5 minutes.\n- `cleanupInterval`: interval in milliseconds for cleaning up expired entries. Defaults to 5 minutes.\n- `logger`: custom logger implementation. Defaults to the common logger.\n\n## Migration from `store-libsql`\n\nThis package replaces `@alexmchan/memocache-store-libsql`, dropping the `@libsql/client` dependency in favor of the standard library.\n\n1. Swap the dependency and import:\n   ```diff\n   - import { createSqliteStore } from '@alexmchan/memocache-store-libsql'\n   + import { createSqliteStore } from '@alexmchan/memocache-store-sqlite'\n   ```\n2. Replace the injected client with a `location` (or a `DatabaseSync`):\n   ```diff\n   - import { createClient } from '@libsql/client'\n   - const sqliteClient = createClient({ url: 'file::memory:' })\n   - const store = createSqliteStore({ sqliteClient })\n   + const store = createSqliteStore({ location: ':memory:' })\n   ```\n3. **Local databases only.** Turso / remote `libsql://` URLs are not supported by `node:sqlite`. If you relied on a remote database, put a network store (e.g. Redis) in front of it instead — the LibSQL store has been removed.\n\n## Features\n\n- Zero runtime dependencies (standard-library SQLite)\n- Persistent (file) or in-memory storage\n- superjson serialization — `Date`, `Map`, `undefined` round-trip intact\n- Automatic cleanup of expired entries (timer does not keep the process alive)\n- Per-entry TTL overrides\n\n## License\n\nSee the main project license for details.\n","readmeFilename":"README.md","_rev":"1-df007e02ce82f6081348f6925bc9cb73"}