[{"data":1,"prerenderedAt":443},["ShallowReactive",2],{"navigation":3,"\u002Fconcepts\u002Fstrict-vs-lax":151,"\u002Fconcepts\u002Fstrict-vs-lax-surround":438},[4,29,56,79,94,121,128,144],{"title":5,"path":6,"stem":7,"children":8,"icon":27,"defaultOpen":28},"Getting Started","\u002Fgetting-started","1.getting-started\u002F1.index",[9,12,17,22],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-book-open",{"title":13,"path":14,"stem":15,"icon":16},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Redis setup","\u002Fgetting-started\u002Fredis-setup","1.getting-started\u002F3.redis-setup","i-lucide-database",{"title":23,"path":24,"stem":25,"icon":26},"Quickstart","\u002Fgetting-started\u002Fquickstart","1.getting-started\u002F4.quickstart","i-lucide-zap","i-lucide-rocket",true,{"title":30,"icon":31,"path":32,"stem":33,"children":34,"page":55},"Concepts","i-lucide-lightbulb","\u002Fconcepts","2.concepts",[35,40,45,50],{"title":36,"path":37,"stem":38,"icon":39},"Keys","\u002Fconcepts\u002Fkeys","2.concepts\u002F1.keys","i-lucide-key-round",{"title":41,"path":42,"stem":43,"icon":44},"Strict vs lax","\u002Fconcepts\u002Fstrict-vs-lax","2.concepts\u002F2.strict-vs-lax","i-lucide-scale",{"title":46,"path":47,"stem":48,"icon":49},"Comparators","\u002Fconcepts\u002Fcomparators","2.concepts\u002F3.comparators","i-lucide-git-compare",{"title":51,"path":52,"stem":53,"icon":54},"Errors","\u002Fconcepts\u002Ferrors","2.concepts\u002F4.errors","i-lucide-triangle-alert",false,{"title":57,"path":58,"stem":59,"children":60,"icon":63},"Counters","\u002Fcounters","3.counters\u002F1.index",[61,64,69,74],{"title":62,"path":58,"stem":59,"icon":63},"Overview","i-lucide-hash",{"title":65,"path":66,"stem":67,"icon":68},"StrictCounter","\u002Fcounters\u002Fstrict-counter","3.counters\u002F2.strict-counter","i-lucide-target",{"title":70,"path":71,"stem":72,"icon":73},"LaxCounter","\u002Fcounters\u002Flax-counter","3.counters\u002F3.lax-counter","i-lucide-wind",{"title":75,"path":76,"stem":77,"icon":78},"Conditional & batch operations","\u002Fcounters\u002Fconditional-and-batch","3.counters\u002F4.conditional-and-batch","i-lucide-layers",{"title":80,"path":81,"stem":82,"children":83,"icon":85},"Instance-aware counters","\u002Finstance-aware-counters","4.instance-aware-counters\u002F1.index",[84,86,90],{"title":62,"path":81,"stem":82,"icon":85},"i-lucide-network",{"title":87,"path":88,"stem":89,"icon":68},"StrictInstanceAwareCounter","\u002Finstance-aware-counters\u002Fstrict","4.instance-aware-counters\u002F2.strict",{"title":91,"path":92,"stem":93,"icon":73},"LaxInstanceAwareCounter","\u002Finstance-aware-counters\u002Flax","4.instance-aware-counters\u002F3.lax",{"title":95,"path":96,"stem":97,"children":98,"icon":100},"Locks","\u002Flocks","5.locks\u002F1.index",[99,101,106,111,116],{"title":62,"path":96,"stem":97,"icon":100},"i-lucide-lock",{"title":102,"path":103,"stem":104,"icon":105},"Mutex","\u002Flocks\u002Fmutex","5.locks\u002F2.mutex","i-lucide-lock-keyhole",{"title":107,"path":108,"stem":109,"icon":110},"RwLock","\u002Flocks\u002Frwlock","5.locks\u002F3.rwlock","i-lucide-book-lock",{"title":112,"path":113,"stem":114,"icon":115},"Lock options","\u002Flocks\u002Foptions","5.locks\u002F4.options","i-lucide-sliders-horizontal",{"title":117,"path":118,"stem":119,"icon":120},"Guard state & errors","\u002Flocks\u002Fguard-state","5.locks\u002F5.guard-state","i-lucide-shield-alert",{"title":122,"path":123,"stem":124,"children":125,"icon":127},"Rate limiting","\u002Frate-limiting","6.rate-limiting\u002F1.index",[126],{"title":122,"path":123,"stem":124,"icon":127},"i-lucide-gauge",{"title":129,"icon":130,"path":131,"stem":132,"children":133,"page":55},"Reference","i-lucide-book-marked","\u002Freference","7.reference",[134,139],{"title":135,"path":136,"stem":137,"icon":138},"Feature flags","\u002Freference\u002Ffeature-flags","7.reference\u002F1.feature-flags","i-lucide-flag",{"title":140,"path":141,"stem":142,"icon":143},"API reference","\u002Freference\u002Fapi","7.reference\u002F2.api","i-lucide-file-code",{"title":145,"path":146,"stem":147,"children":148,"icon":150},"Changelog","\u002Fchangelog","8.changelog\u002F1.index",[149],{"title":145,"path":146,"stem":147,"icon":150},"i-lucide-scroll",{"id":152,"title":41,"badge":153,"body":154,"date":153,"description":432,"extension":433,"links":153,"meta":434,"navigation":435,"path":42,"seo":436,"stem":43,"__hash__":437},"docs\u002F2.concepts\u002F2.strict-vs-lax.md",null,{"type":155,"value":156,"toc":423},"minimark",[157,161,166,174,177,181,205,208,212,406,410,413],[158,159,160],"p",{},"distkit's counters come in two flavors, and the same split shows up again in the instance-aware counters. Understanding it once explains both.",[162,163,165],"h2",{"id":164},"strict-correctness-first","Strict: correctness first",[158,167,168,169,173],{},"A ",[170,171,172],"strong",{},"strict"," counter executes every operation as an atomic Lua script on Redis. Each call is one round-trip, and a read always reflects the latest write from anywhere in the cluster.",[158,175,176],{},"Use strict counters when an off-by-one matters: billing, inventory, quota enforcement, anything you would be uncomfortable approximating.",[162,178,180],{"id":179},"lax-throughput-first","Lax: throughput first",[158,182,168,183,186,187,191,192,195,196,199,200,204],{},[170,184,185],{},"lax"," counter buffers increments in a local ",[188,189,190],"code",{},"DashMap"," and flushes them to Redis in batched pipelines on an interval (",[188,193,194],{},"allowed_lag",", default ~20 ms). Increments return almost instantly because they never touch the network on the hot path. Reads return the local view (",[188,197,198],{},"remote_total + pending_delta","), which is always consistent ",[201,202,203],"em",{},"within the same process"," but may lag what other processes have flushed.",[158,206,207],{},"Use lax counters for analytics and high-throughput metrics, where a few milliseconds of cross-process lag is fine and per-call Redis I\u002FO would be the bottleneck.",[162,209,211],{"id":210},"side-by-side","Side by side",[213,214,215,240],"table",{},[216,217,218],"thead",{},[219,220,221,224,228,232,236],"tr",{},[222,223],"th",{},[222,225,226],{},[188,227,65],{},[222,229,230],{},[188,231,70],{},[222,233,234],{},[188,235,87],{},[222,237,238],{},[188,239,91],{},[241,242,243,266,286,306,329,346,361,387],"tbody",{},[219,244,245,251,254,257,259],{},[246,247,248],"td",{},[170,249,250],{},"Consistency",[246,252,253],{},"Immediate",[246,255,256],{},"Eventual (~20 ms default)",[246,258,253],{},[246,260,261,262,265],{},"Eventual (",[188,263,264],{},"flush_interval",")",[219,267,268,276,279,282,284],{},[246,269,270],{},[170,271,272,275],{},[188,273,274],{},"inc"," latency",[246,277,278],{},"Redis round-trip",[246,280,281],{},"Sub-microsecond (warm path)",[246,283,278],{},[246,285,281],{},[219,287,288,293,296,299,304],{},[246,289,290],{},[170,291,292],{},"Redis I\u002FO",[246,294,295],{},"Every operation",[246,297,298],{},"Batched on interval",[246,300,301,302],{},"Every ",[188,303,274],{},[246,305,298],{},[219,307,308,319,321,323,326],{},[246,309,310],{},[170,311,312,315,316],{},[188,313,314],{},"set"," \u002F ",[188,317,318],{},"del",[246,320,253],{},[246,322,253],{},[246,324,325],{},"Immediate (bumps epoch)",[246,327,328],{},"Flushes pending delta, then immediate",[219,330,331,336,339,341,344],{},[246,332,333],{},[170,334,335],{},"Per-instance tracking",[246,337,338],{},"No",[246,340,338],{},[246,342,343],{},"Yes",[246,345,343],{},[219,347,348,353,355,357,359],{},[246,349,350],{},[170,351,352],{},"Dead-instance cleanup",[246,354,338],{},[246,356,338],{},[246,358,343],{},[246,360,343],{},[219,362,363,368,374,378,383],{},[246,364,365],{},[170,366,367],{},"Feature flag",[246,369,370,373],{},[188,371,372],{},"counter"," (default)",[246,375,376,373],{},[188,377,372],{},[246,379,380],{},[188,381,382],{},"instance-aware-counter",[246,384,385],{},[188,386,382],{},[219,388,389,394,397,400,403],{},[246,390,391],{},[170,392,393],{},"Use case",[246,395,396],{},"Billing, inventory, exact global count",[246,398,399],{},"Analytics, high-throughput metrics",[246,401,402],{},"Connection counts, exact live metrics",[246,404,405],{},"High-frequency per-node throughput metrics",[162,407,409],{"id":408},"a-rule-of-thumb","A rule of thumb",[158,411,412],{},"Reach for strict by default. Switch to lax only when you have measured that per-call Redis round-trips are your bottleneck and you can tolerate a small, bounded lag.",[158,414,415,416,419,420,422],{},"See ",[417,418,57],"a",{"href":58}," for the API and ",[417,421,80],{"href":81}," for the per-instance variants.",{"title":424,"searchDepth":425,"depth":426,"links":427},"",1,2,[428,429,430,431],{"id":164,"depth":426,"text":165},{"id":179,"depth":426,"text":180},{"id":210,"depth":426,"text":211},{"id":408,"depth":426,"text":409},"The consistency trade-off that runs through distkit's counters.","md",{},{"icon":44},{"title":41,"description":432},"aooBRmCaDwXF8-3GttceGAJFSBE9al-CccU5GzOIPvI",[439,441],{"title":36,"path":37,"stem":38,"description":440,"icon":39,"children":-1},"DistkitRedisKey wraps and validates every key distkit writes to Redis.",{"title":46,"path":47,"stem":48,"description":442,"icon":49,"children":-1},"CounterComparator drives conditional counter writes.",1781569582557]