Skip to main content

Automatic Increment and Decrement

Increments or decrements a data value by specified numeric amount. If data key does not exist, the default value is 0.

Call Information

CacheIncrby(String dataKey, Integer dataValue,  Integer dataTtl, PlayNANOODelegate callback) {}
CacheDecrby(String dataKey, Integer dataValue, Integer dataTtl, PlayNANOODelegate callback) {}

Call Information Details

ParameterDescriptionType
dataKeyCache data keystring
dataValueCache data valuestring
dataTtlCache data expiration time (In seconds)integer
callbackCommunication resultPlayNANOODelegate

Source Code

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();

// Increment
string dataKey = "string";
int dataValue = 1;
int dataTtl = 60;
plugin.CacheIncrby(dataKey, dataValue, dataTtl, (state, message, rawData, dictionary) => {
if (state.Equals(Configure.PN_API_STATE_SUCCESS))
{
Debug.Log(dictionary["value"].ToString());
}
else
{
Debug.Log("Fail");
}
});

// Decrement
plugin.CacheDecrby(dataKey, dataValue, dataTtl, (state, message, rawData, dictionary) => {
if (state.Equals(Configure.PN_API_STATE_SUCCESS))
{
Debug.Log(dictionary["value"].ToString());
}
else
{
Debug.Log("Fail");
}
});
}
}

Communication Result

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"code" : 200,
"message" : 0,
"value" : "integer
}

Communication Result

Data KeyDescriptionType
valueResult value after increment or decrementinteger