Skip to content

feat(cache_sqlite): add SQLite cache backend (#1)#12

Open
VincentGuyader wants to merge 4 commits into
mainfrom
feat/cache-sqlite-1
Open

feat(cache_sqlite): add SQLite cache backend (#1)#12
VincentGuyader wants to merge 4 commits into
mainfrom
feat/cache-sqlite-1

Conversation

@VincentGuyader
Copy link
Copy Markdown
Member

Summary

  • New cache_sqlite R6 backend with the same API as cache_postgres / cache_mongo / cache_redis. Runs against :memory: (default, ideal for tests) or a file path for a persistent cache. {memoise}-compatible.
  • set() upserts (overwrites an existing key) instead of being a silent no-op, matching the {memoise} cache contract.
  • When the cache table already exists, validate that the schema is (id, cache) before reusing it; raise a clear error otherwise.
  • Test suite gates docker-backed cache_redis / cache_mongo / cache_postgres tests behind skip_if_not_installed() and a docker availability check, so a sandbox without those backends no longer fails the suite. The optional install.packages() calls in helpers-utils.R are now non-fatal.

RSQLite moved from implicit to Suggests.

Test plan

  • R CMD check on Ubuntu (release): 0 ERROR / 0 WARNING / 2 NOTEs (pre-existing).
  • tests/testthat/test-sqlite.R: 15 PASS (in-memory + file-backed round-trip, schema validation, {memoise} integration, set() overwrite).

Closes #1

Pure-R, zero-service backend usable as ':memory:' for unit tests and as a
file path for a persistent on-disk cache. Follows the same surface as
cache_postgres / cache_mongo / cache_redis and is fully {memoise}-compatible.

- RSQLite moved from implicit to suggested.
- tests/testthat/test-sqlite.R exercises the full surface in-memory.
…used import

- set() now overwrites an existing key instead of being a silent no-op,
  matching the {memoise} cache contract. Old behaviour confused callers
  that expected the cache to reflect the latest assigned value.
- When the cache table already exists, validate that its columns are
  exactly (id, cache) before reusing it; otherwise raise a readable
  error instead of failing later inside an INSERT/SELECT.
- Drop the orphan @importFrom attempt stop_if_not (no call sites).
R CMD check ran the redis/mongo/postgres tests on machines without
those packages installed (or without docker), which meant a clean
sandbox failed the whole suite even though cache_sqlite is pure-R.
Add skip_if_not_installed() and a docker-availability skip to each
test, and make the helper's optional install.packages() calls
non-fatal when the repo is unreachable.
@VincentGuyader VincentGuyader self-assigned this Apr 26, 2026
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.

Additional database backends

1 participant