llUpdateKeyValue

From Second Life Wiki
Revision as of 13:31, 8 July 2014 by Jeremy Linden (talk | contribs) (Created page with "Category:Experience Tools {{LSL_Function |func=llUpdateKeyValue |func_desc=Start an asynchronous transaction to update a key-value pair associated with the given experience k…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Function: key llUpdateKeyValue( string k, string v, integer checked, string ov );

Start an asynchronous transaction to update a key-value pair associated with the given experience key with the given key and value.
Returns a key Returns the ID of the transaction

• string k They key for the key-value pair
• string v The value for the key-value pair. Maximum 2047 characters, or 4095 characters if using Mono.
• integer checked TRUE if the original value is given and the update should be "checked" to make sure it is "atomic".
• string ov The original value to compare with the current value in the key-value store to make sure the update is "atomic".

Optionally, if "checked" is set to TRUE and an original value is given, then the update will check the current value before applying the update. If the supplied original value doesn't match the current value in the key-value store, the update will not be applied. This allows the caller to be certain that their update was "atomic" and no other script changed the value between when they read it and when they are updating it.

The dataserver callback parameters are:

  • A key containing the transaction ID returned from llUpdateKeyValue
  • A string containing a comma-delimited list. The first item is a boolean specifying if the transaction succeeded (1) or not (0). The second item is a string with a status/error message if it failed or the value if the transaction succeeded.

Examples

<lsl>key trans; default {

   state_entry()
   {
       trans = llUpdateKeyValue("FOO", "BLAH", TRUE, "BAR");
   }

}

dataserver(key t, string value) {

   if (t == trans)
   {
       // our llUpdateKeyValue transaction is done
       list result = llCSV2List(value);
       if (llList2Integer(result, 0) == 1)
       {
           // the key-value pair was successfully updated
           llSay(0, "New key-value pair was successfully updated");
       }
       else if(llList2Integer(result, 1) == "retry update")
       {
           llSay(0, "Key-value update failed, checked value is out of date");
       }
       else
       {
           llSay(0, "Key-value update failed: " + llList2String(result, 1) );
       }  
   } 
}</lsl>

Deep Notes

Search JIRA for related Issues

Signature

function key llUpdateKeyValue( string k, string v, integer checked, string ov );