Start typing to search packages!
session-service
By @vyon
Roblox
MirroredSessionService
SessionService is a simple data management service inspired by real world uses of databases.
The service is designed to utilize sharding and load and unload data as needed. Similar to how DataStore2 works in Roblox. Also taking the great stuff from ProfileService and essentially fusing the 2 together.
The great thing about this service is that there is a lot of flexibility when it comes to changing data. You can change the data from the instance data (PlayerData folder). This allows you to have a lot of control over how you want to manage your data.
Usage
Basic Usage
-- Services:
local Players = game:GetService("Players")
-- Modules:
local SessionService = require(script.SessionService)
-- Variables:
local Store = SessionService:GetStore("MyDataStore", {
Coins = 0,
})
-- Functions:
local function PlayerAdded(Player: Player)
print(Player.Name, "has joined!")
-- Load data:
local _, Data = Store:LoadAsync(Player)
:catch(function(Error: string)
warn(Error)
end)
:await()
-- Do stuff with data:
print(Data.Coins)
-- We can manually save data:
Store:SaveAsync(Player) --> This will queue the data to be saved.
local Session: SessionService.Session = SessionService:GetSession(Store.Name, Player)
Session.Updated:Connect(function(Data: table)
warn("Data updated!")
end)
task.defer(function()
while Player:IsDescendantOf(Players) do
Session:QueueUpdate(function()
Data.Coins += 1
print(Data.Coins)
end)
task.wait(1)
end
end)
end
local function PlayerRemoving(Player: Player)
print(Player.Name, "is leaving!")
-- Unload data:
Store:UnloadAsync(Player)
:catch(function(Error: string)
warn(Error)
end)
:await() --> This will remove the data from the current session, and remove the session lock from the player.
end
-- Connections:
Store.AutoSaveStart:Connect(function()
print("Auto save is starting!")
end)
for _, Player in Players:GetPlayers() do
task.defer(PlayerAdded, Player)
end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(PlayerRemoving)
Documentation
SessionService
Package Details
Install command (Click to copy)
Version
0.1.4
License
MIT
Safe for commercial use
The package archive does not include its license text; the license is declared in its manifest metadata.
Automated license review — not legal advice.
