{"id":"dooougs/server-sync","name":"server-sync","scope":"dooougs","platform":"roblox","description":"Region-sharded shared world store for many Roblox servers: DataStore CAS merges, MemoryStore-leased compaction, MessagingService live sync","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"b3cd1dfc3af0a58a55857a86c20a6bf6f364ecc0fd5af1e266430a5468145bf1","likes":0,"downloads":0,"install":"forest install dooougs/server-sync","url":"https://forest.dev/p/roblox/dooougs/server-sync","files":"https://api.forest.dev/ai/package/roblox/dooougs/server-sync/files","readme":"# ServerSync\r\n\r\nA shared world store for Roblox experiences where many servers edit the same\r\nworld at once. Extracted from Plant World, where it holds every plant in\r\nevery city.\r\n\r\n- **Objects** (written once, first copy wins) and **updates** (per field,\r\n  newest timestamp wins), sharded into one DataStore key per region.\r\n- Saves merge with `UpdateAsync` (compare-and-swap), so servers never\r\n  overwrite each other and nothing ever waits on a lock.\r\n- Old updates are **compacted** into versioned baselines under a try-once\r\n  MemoryStore lease with a fencing check.\r\n- Edits are broadcast live through **MessagingService** in batches sized for\r\n  its 1 KB / per-minute limits; anything missed is caught by periodic\r\n  re-reads.\r\n- Budget-aware reads with jittered back-off, bounded region cache, Studio\r\n  offline mode.\r\n\r\n## Install\r\n\r\n```toml\r\n[server-dependencies]\r\nServerSync = \"dooougs/server-sync@0.1.0\"\r\n```\r\n\r\n## Use\r\n\r\n```lua\r\nlocal ServerSync = require(ServerScriptService.ServerPackages.ServerSync)\r\n\r\nlocal store = ServerSync.newStore({ storeName = \"MyWorld_v1\" })\r\nlocal sync = ServerSync.newBroadcaster(store, { topic = \"MyWorldUpdates_v1\" })\r\nstore.start()\r\nsync.start()\r\n\r\nstore.createObject(\"3,4#1\", { pos = { x = 10, z = 20 }, kind = \"tree\" })\r\nstore.set(\"3,4#1\", \"w\", 0.5)\r\nstore.onChanged(function(id, field, value) print(id, field, value) end)\r\n```\r\n\r\nEntity ids start with their chunk, `\"cx,cz\"`, by default; pass `keys` to map\r\nids to regions your own way.\r\n\r\n## Options\r\n\r\nSee [`src/Options.luau`](src/Options.luau) for every option and default.\r\nHighlights:\r\n\r\n| option | default | |\r\n|---|---|---|\r\n| `storeName` | required | keep it identical to keep existing saves |\r\n| `scope`, `leaseMapName` | none, `<storeName>_compact` | |\r\n| `keys` | `\"cx,cz\"` ids, 8x8-chunk regions | custom id → region mapping |\r\n| `flushInterval` / `refreshInterval` | 30 / 120 s | |\r\n| `refresh`, `eviction` | true | turn re-reads or the region cache off |\r\n| `compaction.enabled` | true | plus `lag`, `minUpdates`, `interval`, `lease`, `tombKeep` |\r\n| `forceOffline`, `studioProbe`, `bindToClose` | false, true, true | |\r\n| broadcaster `publish` / `subscribe` | true | one-way sync, or none |\r\n| broadcaster `publishInterval` / `messageBytes` | 4 s / 900 | |\r\n\r\nThe saved record layout (`v = 3`) is fixed so saves always load.\r\n","readmeTruncated":false}