跳转到主要内容

缓存查询

查询缓存值的 API。

URL 确认

此 API 使用 service-api.playnanoo.com 域名。

API 信息

  • URL: https://service-api.playnanoo.com/cache/v20241201/get
  • Method: PUT
  • 需要认证: 是

请求参数

参数类型必需说明
cache_keystring必需缓存键
DeviceInfo 继承

此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性将自动包含。

响应数据

Res 类

字段类型说明
keystring缓存键
valuestring缓存值

Unity C# 实现

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

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

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

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

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 string value;
}
}

使用示例

public void GetCache()
{
CacheGet.Req req = new CacheGet.Req();

StartCoroutine(req.Send(
cache_key: "player_level",
onSuccess: res =>
{
Debug.Log($"Key: {res.key}, Value: {res.value}");
},
onError: (error) =>
{
Debug.LogError($"Get 실패: [{error.ErrorCode}] [{error.Message}]");
}
));
}