Cache Get
Retrieves a cache value.
Check URL
This API uses the service-api.playnanoo.com domain.
API Information
- URL:
https://service-api.playnanoo.com/cache/v20241201/get - Method:
PUT - Authentication Required: Yes
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| cache_key | string | Required | Cache key |
Response Data
| Field | Type | Description |
|---|---|---|
| key | string | Cache key |
| value | string | Cache value |
Code Example
void UMyGame::GetCache(const FString& CacheKey)
{
// Create request data
// Create request body with player information
TSharedPtr<FJsonObject> Body = FPlayNANOOHelper::CreateRequestBody();
Body->SetStringField(TEXT("cache_key"), CacheKey);
// Convert to JSON string
FString JsonBody = FPlayNANOOHelper::ToJsonString(Body);
// HTTP request
TSharedRef<IHttpRequest> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(TEXT("https://service-api.playnanoo.com/cache/v20241201/get"));
Request->SetVerb(TEXT("PUT"));
FPlayNANOOHelper::SetCommonHeaders(Request, true); // Include auth token
Request->SetContentAsString(JsonBody);
Request->OnProcessRequestComplete().BindLambda(
[](FHttpRequestPtr Req, FHttpResponsePtr Res, bool bSuccess)
{
if (bSuccess && Res.IsValid())
{
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Res->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
FString Key = JsonObject->GetStringField(TEXT("key"));
FString Value = JsonObject->GetStringField(TEXT("value"));
UE_LOG(LogTemp, Log, TEXT("Cache retrieval successful: %s = %s"), *Key, *Value);
}
}
});
Request->ProcessRequest();
}
Cache Expiration
When a cache's TTL expires, it will return an empty value upon retrieval.