PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

UpdateAsync

Retrieves the value of a key from a sorted map and lets you update it to a new value via a callback function.

This method accepts a callback function that transforms the old value into the updated value as required. The method retrieves the existing key value and passes it to the transform function which returns the new value for the item, with these exceptions:

  • If the key does not exist, the old value passed to the function will be nil.
  • If the function returns nil, the update is canceled.

The new value is saved only if the key was not updated (e.g. by a different game server) since the moment it was read. If the value did change, the transform function is invoked again with the most recent item value. This cycle repeats until the value is saved successfully or the transform function returns nil to abort the operation.

For a more in-depth look, take a look at the articles/Memory Store|Memory Store article.

Parameters

Name Type Default Description

key

Key whose value to update.

A function which you need to provide. The function takes the key’s old value as input and returns the new value.

Item expiration time, in seconds, after which the item will be automatically removed from the sorted map.

Returns

Return Type Summary

The return value is the last value returned by the transform function.