{"id":"ernisto/re-save","name":"re-save","scope":"ernisto","platform":"roblox","description":"A lock-less data store library.","version":"0.1.0-alpha.1","latest":"0.1.0-alpha.1","versions":["0.1.0-alpha.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"11c3bcfb6dbbb92f8ff7747595050ce4e3a286a373a0aec4de92f8a6ca9a22b4","likes":0,"downloads":0,"install":"forest install ernisto/re-save","url":"https://forest.dev/p/roblox/ernisto/re-save","files":"https://api.forest.dev/ai/package/roblox/ernisto/re-save/files","readme":"<p align=\"center\">\n\t<img src=\"scripts/docgen/site/icon.svg\" width=\"96\" alt=\"re-save icon\">\n</p>\n\n<h1 align=\"center\">re-save</h1>\n\n<p align=\"center\">\n\tSession-based DataStore saving for Roblox, with an oplog, schema migrations and multi-key transactions.\n</p>\n\n<p align=\"center\">\n\t<a href=\"https://github.com/ernisto/re-save/actions/workflows/check.yml\"><img src=\"https://github.com/ernisto/re-save/actions/workflows/check.yml/badge.svg\" alt=\"Tests\"></a>\n</p>\n\n<p align=\"center\">\n\t<a href=\"https://ernisto.github.io/re-save/\">Docs</a> ·\n\t<a href=\"https://ernisto.github.io/re-save/#tutorials\">Tutorials</a> ·\n\t<a href=\"https://ernisto.github.io/re-save/#examples\">Examples</a> ·\n\t<a href=\"https://ernisto.github.io/re-save/#reference\">API Reference</a> ·\n\t<a href=\"https://github.com/ernisto/re-save/releases/latest/download/resave.rbxm\">Download</a>\n</p>\n\n## Features\n\n- **No session locks**: a key can be open on more than one server. Each session keeps its changes in an oplog and replays them on the newest saved data, so no change is lost.\n- **Change now, save later**: `queueupdate` changes `session.data` at once; the oplog is saved in the background, on `free` and on shutdown.\n- **Versioned schemas**: migrations upgrade old saves when they load, and are test-run when the schema is built, so a broken one fails at startup.\n- **Transactions**: `savebatch` changes several keys at once, or none of them.\n\n## Installation\n\n- **Wally**: add to `wally.toml`, then run `wally install`\n```toml\n[server-dependencies]\nresave = \"ernisto/re-save@0.1.0-alpha.7\"\n```\n\n- **pesde**:\n```sh\npesde add wally#ernisto/re-save\n```\n\n- **Model file**: [download `resave.rbxm`](https://github.com/ernisto/re-save/releases/latest/download/resave.rbxm) from the [latest release](https://github.com/ernisto/re-save/releases/latest) and put it in ServerScriptService.\n\n## Quick look\n\n```luau\nlocal Players = game:GetService 'Players'\nlocal ServerScriptService = game:GetService 'ServerScriptService'\nlocal resave = require(ServerScriptService.ServerPackages.resave)\n\nlocal players = resave.store('players', {\n\tschema = resave.schema { coins = 0 },\n})\n\nPlayers.PlayerAdded:Connect(function(player)\n\tlocal err = resave.track(players, tostring(player.UserId))\n\tif err then player:Kick 'Could not load your data, please rejoin' end\nend)\n\nPlayers.PlayerRemoving:Connect(function(player)\n\tlocal session = resave.maybetracked(players, tostring(player.UserId))\n\tif session then resave.free(session) end\nend)\n\nlocal function earn(player, amount)\n\tlocal session = resave.maybetracked(players, tostring(player.UserId))\n\tif not session then return end\n\n\tresave.queueupdate(session, function(data)\n\t\tdata.coins += amount\n\tend)\nend\n```\n\nNew here? Start with the [tutorials](https://ernisto.github.io/re-save/#tutorials).\n\n## License\n\n[MIT](LICENSE). re-save is rewritten from [drop](https://github.com/jackhexed/drop) by [jackhexed](https://github.com/jackhexed) (formerly jackdotink), also MIT licensed.\n","readmeTruncated":false}