Skip to main content

Cache Multiple Get

API for retrieving multiple cache values at once.

URL Confirmation

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

API Information

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

Request Parameters

ParameterTypeRequiredDescription
cache_keysList\<string>RequiredList of cache keys to retrieve
DeviceInfo Inheritance

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

Response Data

Res Class

FieldTypeDescription
ItemsList\<CacheItems>List of cache items

CacheItems Structure

FieldTypeDescription
keystringCache key
valuestringCache value

Unity C# Implementation

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

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

[Serializable]
public class Req : DeviceInfo
{
public List<string> cache_keys;

public IEnumerator Send(List<string> cacheKeys, Action<Res> onSuccess, Action<BaseResponse> onError)
{
this.cache_keys = cacheKeys;

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

[Serializable]
public class Res : BaseResponse
{
public List<CacheItems> Items;
}

[Serializable]
public class CacheItems
{
public string key;
public string value;
}
}

Usage Example

public void GetMultipleCaches()
{
CacheMultiGet.Req req = new CacheMultiGet.Req();

List<string> keys = new List<string>
{
"player_level",
"player_score",
"player_hp"
};

StartCoroutine(req.Send(
cacheKeys: keys,
onSuccess: res =>
{
foreach (var item in res.Items)
{
Debug.Log($"{item.key}: {item.value}");
}
},
onError: (error) =>
{
Debug.LogError($"Mget failed: [{error.ErrorCode}] [{error.Message}]");
}
));
}