[{"data":1,"prerenderedAt":465},["ShallowReactive",2],{"navigation":3,"\u002Finstance-aware-counters":151,"\u002Finstance-aware-counters-surround":460},[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":62,"badge":153,"body":154,"date":153,"description":454,"extension":455,"links":153,"meta":456,"navigation":457,"path":81,"seo":458,"stem":82,"__hash__":459},"docs\u002F4.instance-aware-counters\u002F1.index.md",null,{"type":155,"value":156,"toc":448},"minimark",[157,171,178,255,260,282,286,293,363,369,373,397,403,407,414,444],[158,159,160,161,165,166,170],"p",{},"Instance-aware counters track each running instance's contribution separately. The ",[162,163,164],"strong",{},"cumulative total is the sum of all live instances",". When an instance stops heartbeating for longer than ",[167,168,169],"code",{},"dead_instance_threshold_ms"," (default 30 s), its slice is automatically removed from the cumulative the next time any surviving instance touches the same key.",[158,172,173,174,177],{},"They live behind the ",[167,175,176],{},"instance-aware-counter"," feature:",[179,180,185],"pre",{"className":181,"code":182,"language":183,"meta":184,"style":184},"language-toml shiki shiki-themes material-theme-lighter github-light github-dark","[dependencies]\ndistkit = { version = \"0.5\", features = [\"instance-aware-counter\"] }\n","toml","",[167,186,187,203],{"__ignoreMap":184},[188,189,192,196,200],"span",{"class":190,"line":191},"line",1,[188,193,195],{"class":194},"sP7_E","[",[188,197,199],{"class":198},"sbgvK","dependencies",[188,201,202],{"class":194},"]\n",[188,204,206,210,213,216,219,221,225,229,232,235,238,240,243,245,247,249,252],{"class":190,"line":205},2,[188,207,209],{"class":208},"su5hD","distkit ",[188,211,212],{"class":194},"=",[188,214,215],{"class":194}," {",[188,217,218],{"class":208}," version ",[188,220,212],{"class":194},[188,222,224],{"class":223},"sjJ54"," \"",[188,226,228],{"class":227},"s_sjI","0.5",[188,230,231],{"class":223},"\"",[188,233,234],{"class":194},",",[188,236,237],{"class":208}," features ",[188,239,212],{"class":194},[188,241,242],{"class":194}," [",[188,244,231],{"class":223},[188,246,176],{"class":227},[188,248,231],{"class":223},[188,250,251],{"class":194},"]",[188,253,254],{"class":194}," }\n",[256,257,259],"h2",{"id":258},"when-they-fit","When they fit",[261,262,263,270,276],"ul",{},[264,265,266,269],"li",{},[162,267,268],{},"Connection pool sizing"," - each server reports its own active connections; the cumulative is the cluster-wide total.",[264,271,272,275],{},[162,273,274],{},"Live session counting"," - a node's contribution disappears on its own when it restarts or crashes.",[264,277,278,281],{},[162,279,280],{},"Per-node metrics"," - you can see both the global total and each instance's individual slice.",[256,283,285],{"id":284},"the-shape-of-every-call","The shape of every call",[158,287,288,289,292],{},"Operations return a pair ",[167,290,291],{},"(cumulative, instance_count)"," - the global total and this instance's own slice:",[179,294,298],{"className":295,"code":296,"language":297,"meta":184,"style":184},"language-rust shiki shiki-themes material-theme-lighter github-light github-dark","let (total, mine) = counter.inc(&key, 5).await?;\n","rust",[167,299,300],{"__ignoreMap":184},[188,301,302,306,309,312,314,317,320,324,327,330,334,337,340,343,345,349,351,353,357,360],{"class":190,"line":191},[188,303,305],{"class":304},"sbsja","let",[188,307,308],{"class":194}," (",[188,310,311],{"class":208},"total",[188,313,234],{"class":194},[188,315,316],{"class":208}," mine",[188,318,319],{"class":194},")",[188,321,323],{"class":322},"smGrS"," =",[188,325,326],{"class":208}," counter",[188,328,329],{"class":322},".",[188,331,333],{"class":332},"sGLFI","inc",[188,335,336],{"class":194},"(",[188,338,339],{"class":322},"&",[188,341,342],{"class":208},"key",[188,344,234],{"class":194},[188,346,348],{"class":347},"srdBf"," 5",[188,350,319],{"class":194},[188,352,329],{"class":322},[188,354,356],{"class":355},"sVHd0","await",[188,358,359],{"class":322},"?",[188,361,362],{"class":194},";\n",[158,364,365,366,329],{},"Each instance is assigned a UUID on construction, readable via ",[167,367,368],{},"instance_id()",[256,370,372],{"id":371},"the-two-variants","The two variants",[261,374,375,383],{},[264,376,377,382],{},[378,379,380],"a",{"href":88},[167,381,87],{}," - every call is immediately consistent.",[264,384,385,389,390,392,393,396],{},[378,386,387],{"href":92},[167,388,91],{}," - ",[167,391,333],{},"\u002F",[167,394,395],{},"dec"," buffer locally and flush on an interval.",[158,398,399,400,329],{},"Both implement ",[167,401,402],{},"InstanceAwareCounterTrait",[256,404,406],{"id":405},"conditional-writes","Conditional writes",[158,408,409,410,413],{},"The same ",[378,411,412],{"href":47},"comparator"," model applies, with one nuance:",[261,415,416,429,438],{},[264,417,418,421,422,425,426,329],{},[167,419,420],{},"inc_if"," \u002F ",[167,423,424],{},"set_if"," compare against the ",[162,427,428],{},"cumulative total",[264,430,431,434,435,329],{},[167,432,433],{},"set_on_instance_if"," compares against ",[162,436,437],{},"this instance's slice",[264,439,440,441,443],{},"A failed comparison returns the current ",[167,442,291],{}," unchanged.",[445,446,447],"style",{},"html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}",{"title":184,"searchDepth":191,"depth":205,"links":449},[450,451,452,453],{"id":258,"depth":205,"text":259},{"id":284,"depth":205,"text":285},{"id":371,"depth":205,"text":372},{"id":405,"depth":205,"text":406},"Counters where each instance owns a slice of the total, with automatic cleanup of dead instances.","md",{},{"icon":85},{"title":62,"description":454},"aETxj97SMTb3fbdoyw9_Eon3YRmkOJ6OT4S50KmU7Z8",[461,463],{"title":75,"path":76,"stem":77,"description":462,"icon":78,"children":-1},"Atomic compare-and-write and ordered batch operations on counters.",{"title":87,"path":88,"stem":89,"description":464,"icon":68,"children":-1},"Immediately consistent per-instance counting with epoch-based correctness.",1781569581680]