캐시 조회
캐시 값을 조회하는 API입니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/cache/v20241201/get - Method:
PUT - 인증 필요: 예
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| cache_key | string | 필수 | 캐시 키 |
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| key | string | 캐시 키 |
| value | string | 캐시 값 |
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}]");
}
));
}