feat(cache_sqlite): add SQLite cache backend (#1)#12
Open
VincentGuyader wants to merge 4 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cache_sqliteR6 backend with the same API ascache_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.(id, cache)before reusing it; raise a clear error otherwise.cache_redis/cache_mongo/cache_postgrestests behindskip_if_not_installed()and adockeravailability check, so a sandbox without those backends no longer fails the suite. The optionalinstall.packages()calls inhelpers-utils.Rare now non-fatal.RSQLitemoved from implicit toSuggests.Test plan
R CMD checkon 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