Skip to main content

DataStoreLockUtils

This item only works when running on the server. Server

Pure reading and writing of the session-lock envelope a DataStore keeps under the lock field.

DataStoreLockHelper owns the live path, where the lock is only ever touched by the session that holds it. Tooling needs the other path: inspect or clear the lock on a key belonging to a player who is not in this server, through a raw datastore write with no session at all. Both go through here so there is one definition of the envelope.

Functions

deserializeSessionData

DataStoreLockUtils.deserializeSessionData(sessionDataany) → LockedSessionData?

Reads session data back out of whatever the datastore returned, rejecting anything malformed.

deserializeLockData

DataStoreLockUtils.deserializeLockData(lockDataany) → LockData?

Reads a lock envelope back out of whatever the datastore returned.

readLock

DataStoreLockUtils.readLock(
dataany--

the raw value stored at the key

) → LockData?

Reads the lock off a whole stored profile.

createLockData

DataStoreLockUtils.createLockData(
sessionDataLockedSessionData,
lastUpdateTimenumber?--

defaults to now

) → LockData

Builds the envelope a session writes to claim the key.

withLock

DataStoreLockUtils.withLock(
dataany,--

the raw value stored at the key

lockDataLockData?
) → any

Returns a copy of the profile with the lock set to lockData, or cleared when it is nil.

toHumanReadable

DataStoreLockUtils.toHumanReadable(lockDataLockData?) → string

Renders a lock for a human reading command output.

Show raw api
{
    "functions": [
        {
            "name": "deserializeSessionData",
            "desc": "Reads session data back out of whatever the datastore returned, rejecting anything malformed.",
            "params": [
                {
                    "name": "sessionData",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LockedSessionData?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 33,
                "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
            }
        },
        {
            "name": "deserializeLockData",
            "desc": "Reads a lock envelope back out of whatever the datastore returned.",
            "params": [
                {
                    "name": "lockData",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LockData?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 63,
                "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
            }
        },
        {
            "name": "readLock",
            "desc": "Reads the lock off a whole stored profile.",
            "params": [
                {
                    "name": "data",
                    "desc": "the raw value stored at the key",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LockData?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 80,
                "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
            }
        },
        {
            "name": "createLockData",
            "desc": "Builds the envelope a session writes to claim the key.",
            "params": [
                {
                    "name": "sessionData",
                    "desc": "",
                    "lua_type": "LockedSessionData"
                },
                {
                    "name": "lastUpdateTime",
                    "desc": "defaults to now",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LockData"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 95,
                "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
            }
        },
        {
            "name": "withLock",
            "desc": "Returns a copy of the profile with the lock set to `lockData`, or cleared when it is nil.",
            "params": [
                {
                    "name": "data",
                    "desc": "the raw value stored at the key",
                    "lua_type": "any"
                },
                {
                    "name": "lockData",
                    "desc": "",
                    "lua_type": "LockData?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 109,
                "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
            }
        },
        {
            "name": "toHumanReadable",
            "desc": "Renders a lock for a human reading command output.",
            "params": [
                {
                    "name": "lockData",
                    "desc": "",
                    "lua_type": "LockData?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 128,
                "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "DataStoreLockUtils",
    "desc": "Pure reading and writing of the session-lock envelope a [DataStore] keeps under the `lock` field.\n\n[DataStoreLockHelper] owns the live path, where the lock is only ever touched by the session that\nholds it. Tooling needs the other path: inspect or clear the lock on a key belonging to a player\nwho is not in this server, through a raw datastore write with no session at all. Both go through\nhere so there is one definition of the envelope.",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 13,
        "path": "src/datastore/src/Server/Modules/DataStoreLockUtils.lua"
    }
}