Skip to main content

Cache Increment

API for incrementing cache values.

URL Confirmation

This API uses the service-api.playnanoo.com domain.

API Information

  • URL: https://service-api.playnanoo.com/cache/v20241201/incrby
  • Method: PUT
  • Authentication Required: Yes

Request Parameters

ParameterTypeRequiredDescription
cache_keystringRequiredCache key
cache_valuestringRequiredValue to increment
cache_ttlstringRequiredCache TTL (in seconds)
DeviceInfo Inheritance

The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.

Response Data

Res Class

FieldTypeDescription
keystringCache key
valueintChanged value

Unity C# Implementation

using System;
using System.Collections;
using UnityEngine.Networking;

public class CacheIncrby
{
static string path = "https://service-api.playnanoo.com/cache/v20241201/incrby";

[Serializable]
public class Req : DeviceInfo
{
public string cache_key;
public string cache_value;
public string cache_ttl;

public IEnumerator Send(string cache_key, int cache_value, int cache_ttl, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(cache_key)) this.cache_key = cache_key;
this.cache_value = cache_value.ToString();
this.cache_ttl = cache_ttl.ToString();

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public string key;
public int value;
}
}

Usage Example

public void IncrementCache()
{
CacheIncrby.Req req = new CacheIncrby.Req();

StartCoroutine(req.Send(
cache_key: "player_score",
cache_value: 10,
cache_ttl: 3600,
onSuccess: res =>
{
Debug.Log($"Key: {res.key}, New Value: {res.value}");
},
onError: (error) =>
{
Debug.LogError($"Incrby failed: [{error.ErrorCode}] [{error.Message}]");
}
));
}