Stability: NaN –
Array(16).join("wat" - 1) + " Batman!"
Fetch & cache :origin/_all_docs using a set of lexographically sorted keys
Features · How It Works · Thanks
- 🛋️ Relax! Use the
start_key
andend_key
CouchDB APIs to harness the power of partition-tolerance from the b-tree - 🔑 Accepts a set of lexographically sorted pivots to use as B-tree partitions
- 🦿 Run map-reduce operations on
_all_docs
andpackument
entries by key range or cache partition - 🔜
🕸️⚡️🐢🦎🦀 Lightning fast partition-tolerant edge read-replica forcache-control: immutable
"Pouch-like"[{ _id, _rev, ...doc }*]
JSON documents out of the box!
pnpm install @_all_docs/cache
🐲 🐉 Here. Be. Dragons 🤯 Letting the interface(s) reveal themselves for now. No official interface 🤖
_all_docs_*
bin scripts fornpx
included below
DEBUG=_all_docs* PIVOTS=a.string.array.js npx _all_docs_from_origin
# Inspect partitions fetched to _all_docs cache
ls -al cache/*__*.json
a.string.array.js (naive)
module.exports = [
null,
...numbers,
...atoz
];
DEBUG=_all_docs* npx _all_docs_partipacku A___Z
- 📍 Provide
npm
origin, lexographic pivots, & location for existing cache (if any) - ⚡️ Create
[{ start_key, end_key, id, filename }]
partition ranges from lexographic pivots - 🏃♀️ For each
[start_key, end_key]
partition:- 🗄️ Attempt to read
${start_key}___${end_key}.json
from local disk cache- ✅ Set
max-age=${now-last.now}
s to HTTPheaders
for the outboundundici
options.
- ✅ Set
- ⬇️
GET :npm-origin/_all_docs?start_key={start_key}&end_key={end_key}&include_docs=false
- 🗄️ Attempt to read
- 👀 Validate the HTTP response:
- ✅
304 Not Modified
Local Cache Valid. No update necessary - 📝
200 OK
Update cache contents for${start_key}___${end_key}.json
partition
- ✅
🔜
Many thanks to bmeck, guybedford, mylesborins, mikeal, jhs, jchris, darcyclarke, isaacs, & mcollina for all the code, docs, & past conversations that contributed to this technique working so well, 10 years later ❤️