CyberM.kvp.clear([prefix])
Clears this resource's keys matching a prefix.
Atomically removes every key matching an optional prefix from the calling resource's current-server store and returns the removal count. An empty prefix clears only that resource namespace.
Returns
- removed count, or nil
- reason
Registered in ResourceHost.cpp as LuaKvpClear (line 6532).
CyberM.kvp.compareAndSet(key, expected, replacement)
Atomically changes a key when its typed value matches.
Atomically replaces a key only when its typed value exactly matches the expected value. Nil expected means the key must be absent; nil replacement deletes after a successful comparison.
Parameters
- keystringrequired
- expectedanyrequired
- replacementanyrequired
Returns
- boolean
- reason on storage failure
Registered in ResourceHost.cpp as LuaKvpCas (line 6535).
CyberM.kvp.delete(key)
Deletes one persistent key.
Atomically deletes one key from the current resource store and returns whether it existed. Deleting a missing key succeeds with false.
Returns
- true when removed, false when absent
- reason on storage failure
Registered in ResourceHost.cpp as LuaKvpDelete (line 6529).
CyberM.kvp.find([prefix], [limit])
Finds typed entries by sorted key prefix.
Performs a sorted prefix search in the current resource store and returns bounded {key, value, type} records. The default result limit is 256 and the hard limit is 4096.
Parameters
- prefixstringoptional
- limitintegeroptionaldefault 256
Returns
- array of { key, value, type }, or nil
- reason
Registered in ResourceHost.cpp as LuaKvpFind (line 6530).
CyberM.kvp.get(key, [default])
Reads one typed persistent value.
Reads a typed value from the current connection-address and resource namespace. Missing keys return the optional default (or nil) and are distinct from storage errors, which return nil, reason.
Parameters
- keystringrequired
- defaultanyoptional
Returns
- stored value, default or nil
- reason on storage failure
Registered in ResourceHost.cpp as LuaKvpGet (line 6527).
CyberM.kvp.has(key)
Checks whether a persistent key exists.
Checks whether a key exists in the calling resource's current-server store without exposing its value or any other resource namespace.
Returns
- boolean
- reason on storage failure
Registered in ResourceHost.cpp as LuaKvpHas (line 6528).
CyberM.kvp.increment(key, [delta])
Atomically increments a numeric key.
Atomically creates or increments a numeric key. Integer arithmetic remains 64-bit and rejects overflow; mixed/floating arithmetic rejects non-finite results.
Parameters
- keystringrequired
- deltainteger|numberoptionaldefault 1
Returns
- new numeric value, or nil
- reason
Registered in ResourceHost.cpp as LuaKvpIncrement (line 6533).
CyberM.kvp.keys([prefix], [limit])
Lists sorted keys matching a prefix.
Returns only the sorted keys matching an optional prefix in the current resource store. It is a bounded index query and cannot enumerate another package or connection address.
Parameters
- prefixstringoptional
- limitintegeroptionaldefault 256
Returns
- string array, or nil
- reason
Registered in ResourceHost.cpp as LuaKvpFind (line 6531).
CyberM.kvp.set(key, value)
Persists one typed value for this server address and resource.
Atomically persists a string, signed integer, finite number or boolean under the current connection address and resource. Keys/values and the 1 MiB resource quota are validated before the old file is replaced.
Parameters
- keystringrequired
- valuestring|integer|number|booleanrequired
Returns
- true on success, otherwise false
- reason
Registered in ResourceHost.cpp as LuaKvpSet (line 6526).
CyberM.kvp.setIfAbsent(key, value)
Stores a value only when its key is missing.
Redis-style SETNX for the current resource namespace: atomically stores the typed value only when the key is missing and reports whether insertion occurred.
Parameters
- keystringrequired
- valuestring|integer|number|booleanrequired
Returns
- boolean
- reason on storage failure
Registered in ResourceHost.cpp as LuaKvpSetNx (line 6534).
CyberM.kvp.stats()
Returns this resource store's usage and quotas.
Returns this resource's entry/byte usage and enforced quotas together with the active address/resource scope. It exposes no keys or usage belonging to other resources.
Registered in ResourceHost.cpp as LuaKvpStats (line 6536).