Write Key And Return Previous Value (LCC.kvdb.dict.put)
Signature
old_value, err = LCC.kvdb.dict.put(name, key, value, timeout?)
Parameters
- name
String. Dictionary name (non-empty, max256bytes). - key
String. Key (must be valid UTF-8 and non-empty). - value
String. New value (must be valid UTF-8). - timeout
Number, optional. Request timeout in seconds, default60.
Returns
- old_value
String ornil. Previous value when the key existed;nilfor new keys. - err
String ornil. For new keys this is'not found'; otherwise contains the error message.
Notes
Writes a key and atomically returns its previous value—useful for "set-and-get-old" operations.
When the request fails, the function returnsfalsefollowed by the error message.
Example
local old, err = LCC.kvdb.dict.put("settings", "retry", "3")
if old == false then
error(err)
end