{"id":"xoifaii/ledger","name":"ledger","scope":"xoifaii","platform":"roblox","description":"Lock-free event-sourced player data for Roblox. State is a fold over validated ops, no session locks.","version":"4.1.0","latest":"4.1.0","versions":["1.1.0","1.1.1","2.0.0","2.0.1","2.0.2","2.0.3","2.1.0","2.2.0","3.0.0","3.0.1","3.1.1","3.1.2","3.2.0","3.4.0","4.0.0","4.0.1","4.0.2","4.0.3","4.0.4","4.0.5","4.0.6","4.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"ef1bc363e239ed6ef7f489bbc15b131f4f305fd54fdb3e41c7f9199c3deb4bab","likes":0,"downloads":0,"install":"forest install xoifaii/ledger","url":"https://forest.dev/p/roblox/xoifaii/ledger","files":"https://api.forest.dev/ai/package/roblox/xoifaii/ledger/files","readme":"<div align=\"center\">\n\n# Ledger\n[![GitHub](https://img.shields.io/badge/GitHub-Ledger-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/XoifaiI/Ledger) [![Docs](https://img.shields.io/badge/Docs-Read-8B5CF6?style=for-the-badge)](https://xoifaii.github.io/LedgerDocs/)\n\n</div>\n\n## What is this?\n\nA datastore library for Roblox with no session locks. You never write state. You write down\nthe change you want, a function you own decides whether it is valid, and state is what falls\nout of replaying those changes.\n\n```luau\nlocal Store = Ledger.New({\n\tName = \"PlayerData\",\n\tDefault = { Gold = 100, Items = {} },\n\tReducer = function(State, Op)\n\t\tif Op.Kind == \"SpendGold\" then\n\t\t\tif Op.Amount > State.Gold then\n\t\t\t\treturn nil -- refused, on every server, forever\n\t\t\tend\n\t\t\tlocal Next = table.clone(State)\n\t\t\tNext.Gold -= Op.Amount\n\t\t\treturn Next\n\t\tend\n\t\treturn nil\n\tend,\n})\n\nStore:Load(Player)\nStore:Expect(Player):Apply(\"SpendGold\", { Amount = 25 })\n```\n\nTwo servers spend the same 100 gold, both writes land, the fold accepts one and refuses the\nother. Every server agrees, every time.\n\nA session lock serializes writers. A validating fold makes the invalid state unreachable,\nwhich is a stronger guarantee that also costs nothing when a server crashes: no lease to wait\nout, no locked player join stall, no side channel to touch someone offline or on another\nserver. Changes are ops with names, and a reducer validates them.\n\n## Features\n\n- **Lock free** | every server, same result, no locks\n- **Cross server** | write to any player, even offline\n- **Entity stores** |  clans, listings, world records\n- **Transfers** | escrowed, deduped, self-healing\n- **Transactions** | all keys move or none do\n- **Migrations** | old servers can't corrupt new data\n- **Recovery** | 30 days of history, auto cleanup\n- **Idempotent** | a write retried applies one time\n- **`Once`** | receipts and webhooks land exactly once\n- **Loud misuse** | bad code throws, immediately\n\n## Installing\n\n**Wally**\n\n```toml\n[server-dependencies]\nLedger = \"xoifaii/ledger@4.1.0\"\n```\n\n**Model file**: insert the [Ledger](https://github.com/XoifaiI/Ledger/releases) module anywhere server side.\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/XoifaiI/Ledger/blob/main/LICENSE).\n","readmeTruncated":false}