diigo-cache: SQL in .sql files, behind a read-only facet
No SQL text in the cache logic any more. Statements live in two files, parsed by sqlStatements (`-- name:` sections, as in finquick's brcal/gcbook.js) and imported as text (wrangler Text rule for *.sql): - cache-read.sql: selects only, checked when the module loads - cache-write.sql: schema, the v2 renumbering, etch, drops store.ts turns them into two frozen facets with domain methods: makeReader(sql) runs only the read statements (page, knownTotal, deepestPageSince, pagesThrough); makeWriter(storage) only the write ones (migrate, etch, dropPagesThrough), each change one transaction. The cache migrates in its constructor under blockConcurrencyWhile, as Cloudflare recommends, so readers never meet missing tables; the migration test plants v1 storage and evicts to get a fresh activation. A viewer() facet (PageViewer: stored pages and fill progress, from the reader alone) is added for the public page. Pure refactor: stored state and behavior unchanged. Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
6dd7a37532
commit
a17d287e1d
10 files changed
+275
-122
No files matched your search
@@ -0,0 +1,21 @@
|
||||
-- pageHeader:
|
||||
select total, etched_at from pages where page_num = ? and count = ?;
|
||||
|
||||
-- pageItems:
|
||||
select items.json
|
||||
from page_members
|
||||
join items on items.item_id = page_members.item_id
|
||||
where page_members.page_num = ?
|
||||
order by page_members.pos;
|
||||
|
||||
-- knownTotal:
|
||||
select total from pages where total > 0 order by etched_at desc limit 1;
|
||||
|
||||
-- deepestPageSince:
|
||||
select max(page_members.page_num) as last
|
||||
from page_members
|
||||
join items on items.item_id = page_members.item_id
|
||||
where cast(items.updated as integer) >= ?;
|
||||
|
||||
-- pagesThrough:
|
||||
select count(*) as n from pages where page_num <= ?;
|
||||
Reference in new issue
Block a user