nenu-lang / backend-effects
Stable

Backend Effects

  • throw ends the current path with a failure.
  • log takes a non-empty literal event name and one optional payload expression.
  • cache supports get, set, and delete with a 15-minute default set TTL.

Throwing A Failure

code
1throw "Expense could not be processed"

A throw terminates the current control-flow path. There is no public try, catch, or finally syntax in Nenu.

Logging

code
1log("Starting room balance rebuild")2log("Finished room balance rebuild", total)

log takes a non-empty string literal event name followed by at most one payload expression. Use it for stable execution milestones and useful diagnostic context—not as a substitute for a return value, user-visible toast, or durable record.

NeedUse
Backend diagnostic milestonelog("EventName", optional_payload)
Visible page feedbacktoast.success, toast.warning, or toast.error
API success datareturn Response { ... }
Durable audit historyA project entity saved explicitly

Cache Operations

code
1cache.set("room-summary", summary)2cache.set("room-summary", summary, 3600)3cache.set("room-summary", summary, "1day")4cache.set("room-summary", summary, expires: "1day")56cache.get("room-summary")7cache.delete("room-summary")
OperationMeaning
cache.set(key, value)Store with the default TTL of 15 minutes.
cache.set(key, value, seconds)Store with a numeric TTL in seconds.
cache.set(key, value, duration)Store with a supported duration string.
cache.get(key)Read the cached entry.
cache.delete(key)Remove the cached entry.

Common Mistakes

WrongCorrect
print("done")log("done")
try { ... } catch { ... }Validate first and use throw for failure.
Use log for a user messageUse a Page Script toast.
Put cache reads in need {}Call cache operations in runnable logic.
Use cache as the only copy of an expensePersist authoritative data as entities.

Continue Learning