Cache Decrement
API for decrementing cache values.
URL Confirmation
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/cache/v20241201/decrby - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| cache_key | string | Required | Cache key |
| cache_value | string | Required | Value to decrement |
| cache_ttl | string | Required | Cache 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
| Field | Type | Description |
|---|---|---|
| key | string | Cache key |
| value | int | Changed value |
Unity C# Implementation
using System;
using System.Collections;
using UnityEngine.Networking;
public class CacheDecrby
{
static string path = "https://service-api.playnanoo.com/cache/v20241201/decrby";
[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 DecrementCache()
{
CacheDecrby.Req req = new CacheDecrby.Req();
StartCoroutine(req.Send(
cache_key: "player_hp",
cache_value: 5,
cache_ttl: 3600,
onSuccess: res =>
{
Debug.Log($"Key: {res.key}, New Value: {res.value}");
},
onError: (error) =>
{
Debug.LogError($"Decrby failed: [{error.ErrorCode}] [{error.Message}]");
}
));
}