Auto Increment and Auto Decrement
Increments or decrements data by the specified numeric value. If the 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 Details
| Parameter | Description | Type |
|---|---|---|
| dataKey | Cache data key | string |
| dataValue | Cache data value | string |
| dataTtl | Cache data expiration time (in seconds) | integer |
| callback | Communication Result | PlayNANOODelegate |
Source Code
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;
void Awake()
{
plugin = Plugin.GetInstance();
// 증가
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");
}
});
// 차감
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");
}
});
}
}
Response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"code" : 200,
"message" : 0,
"value" : "integer
}
Response Details
| Data Key | Description | Type |
|---|---|---|
| value | Result value after increment or decrement | integer |