자동 증가 및 자동 차감
지정한 숫자값 만큼 데이터를 증가 또는 차감 합니다.
데이터키가 존재 하지 않는 경우 기본값은 0 입니다.
호출 정보
CacheIncrby(String dataKey, Integer dataValue, Integer dataTtl, PlayNANOODelegate callback) {}
CacheDecrby(String dataKey, Integer dataValue, Integer dataTtl, PlayNANOODelegate callback) {}
호출 상세 정보
파라미터 | 설명 | 타입 |
---|---|---|
dataKey | 캐시 데이터 키 | string |
dataValue | 캐시 데이터 값 | string |
dataTtl | 캐시 데이터 만료 시간 (초단위) | integer |
callback | 통신 결과 | PlayNANOODelegate |
소스 코드
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");
}
});
}
}
통신 결과
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"code" : 200,
"message" : 0,
"value" : "integer
}
통신 결과 상세 정보
데이터키 | 설명 | 타입 |
---|---|---|
value | 증가 또는 차감된 데이터 결과 값 | integer |