BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Sanderling · Carry cache age across a local storage interval

Choose a cache serving mode from stored age, local elapsed time and grace policy.

Carry cache age across a local storage interval

Starting freshness at zero on every cache hop can keep stale content alive. Carry the stored age forward before applying grace. An entry stored at age eight reaches age thirteen after five more ticks. Three ticks of its stale-serving grace remain.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-sanderling.git
cd blyx-sanderling
blyxc native-run project.blyx -- 8 100 105 10 6 0

API and return values

Returns [mode, current age, ticks until mode changes]. Mode 0 serves fresh, 1 serves under explicit stale grace, and 2 requires validation. The host parses and enforces other cache directives. Invalid input returns an empty vector.

ArgumentAccepted input
age_at_storenonnegative finite number
storednonnegative finite number
nownonnegative finite number
lifetimenonnegative finite number
gracenonnegative finite number
mandatorynonnegative exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
1
13
3
Open in the full playground →

Practice

Change mandatory = 1.0. Predict the result, then run the program.

Hint

Returns [mode, current age, ticks until mode changes]. Mode 0 serves fresh, 1 serves under explicit stale grace, and 2 requires validation. The host parses and enforces other cache directives.

Worked solution

The result vector is [2, 13, 0]. Compare its fields with the return layout in the API section.

Find

    let mandatory = 0.0;

Replace with

    let mandatory = 1.0;

Output after the change

2
13
0