logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

do-once - (program-flow)

Description

do-once will execute <any statements> only once in a single process regardless of how many requests that process serves. <any statements> end with end-do-once. The first time a process reaches do-once, <any statements> will execute; in all subsequent cases the program control will skip to immediately after end- do-once. do-once cannot be nested, but otherwise can be used any number of times. Typical use of do-once may be making any calls that need to be performed only once per process, or it may be a one-time setup of process-scoped variables, or anything else that needs to execute just once for all requests served by the same process. <any statements> execute in the nested scope relative to the code surrounding do-once/end-do-once, except that any process-scoped variables are created in the same scope as the code surrounding do-once/end-do- once; this simplifies creation of process-scoped variables, if needed.

Examples

In this example, a process-scoped hash (that is available to multiple requests of a single process) is created in the very first request a process serves and data is written to it; the subsequent requests do not create a new hash but rather just write to it. ... do-once new-hash my_hash hash-size 1024 process-scope end-do-once write-hash my_hash key my_key value my_data ...

Name

do-once - (program-flow)

Purpose

Execute statements only once in a process.

See Also

Program flow break-loopcall-handlercode-blockscontinue-loopdo-onceexit-handlerif-definedif-truequit-processreturn-handlerstart-loop See all documentation $DATE $VERSION GOLF(2gg)

Syntax

do-once <any statements> ... end-do-once

See Also