put player in a player object in the return json and update the cache information in json responses
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 22s
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 22s
This commit is contained in:
48
src/main/java/cc/fascinated/model/cache/CacheInformation.java
vendored
Normal file
48
src/main/java/cc/fascinated/model/cache/CacheInformation.java
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
package cc.fascinated.model.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@AllArgsConstructor @Getter @Setter
|
||||
public class CacheInformation {
|
||||
/**
|
||||
* Whether this request is cached.
|
||||
*/
|
||||
private boolean cached;
|
||||
|
||||
/**
|
||||
* The unix timestamp of when this was cached.
|
||||
*/
|
||||
private long cachedTime;
|
||||
|
||||
/**
|
||||
* Create a new cache information object with the default values.
|
||||
* <p>
|
||||
* The default values are:
|
||||
* <br>
|
||||
* <ul>
|
||||
* <li>cached: true</li>
|
||||
* <li>cachedAt: {@link System#currentTimeMillis()}</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* </p>
|
||||
*
|
||||
* @return the default cache information object
|
||||
*/
|
||||
public static CacheInformation defaultCache() {
|
||||
return new CacheInformation(true, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this request is cached.
|
||||
*
|
||||
* @param cached the new value of if this request is cached
|
||||
*/
|
||||
public void setCached(boolean cached) {
|
||||
this.cached = cached;
|
||||
if (!cached) {
|
||||
cachedTime = -1;
|
||||
}
|
||||
}
|
||||
}
|
@ -24,10 +24,9 @@ public final class CachedEndpointStatus implements Serializable {
|
||||
private final Map<String, Status> endpoints;
|
||||
|
||||
/**
|
||||
* The unix timestamp of when this
|
||||
* server was cached, -1 if not cached.
|
||||
* The cache information about the request.
|
||||
*/
|
||||
private long cached;
|
||||
private CacheInformation cache;
|
||||
|
||||
public enum Status {
|
||||
/**
|
||||
@ -36,10 +35,8 @@ public final class CachedEndpointStatus implements Serializable {
|
||||
ONLINE,
|
||||
|
||||
/**
|
||||
* The service is degraded and may not be fully operational.
|
||||
* <p>
|
||||
* This could be due to high load or other issues.
|
||||
* </p>
|
||||
* The service is online, but may be experiencing issues.
|
||||
* This could be due to high load or other issues.
|
||||
*/
|
||||
DEGRADED,
|
||||
|
||||
|
@ -27,8 +27,7 @@ public final class CachedMinecraftServer implements Serializable {
|
||||
private final MinecraftServer server;
|
||||
|
||||
/**
|
||||
* The unix timestamp of when this
|
||||
* server was cached, -1 if not cached.
|
||||
* The cache information about the request.
|
||||
*/
|
||||
private long cached;
|
||||
private CacheInformation cache;
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package cc.fascinated.model.cache;
|
||||
|
||||
import cc.fascinated.model.mojang.MojangProfile;
|
||||
import cc.fascinated.model.player.Cape;
|
||||
import cc.fascinated.model.player.Player;
|
||||
import cc.fascinated.model.skin.Skin;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -18,17 +17,22 @@ import java.util.UUID;
|
||||
* @author Braydon
|
||||
*/
|
||||
@Setter @Getter
|
||||
@ToString(callSuper = true)
|
||||
@AllArgsConstructor
|
||||
@RedisHash(value = "player", timeToLive = 60L * 60L) // 1 hour (in seconds)
|
||||
public final class CachedPlayer extends Player implements Serializable {
|
||||
public final class CachedPlayer implements Serializable {
|
||||
/**
|
||||
* The unix timestamp of when this
|
||||
* player was cached, -1 if not cached.
|
||||
* The unique id of the player.
|
||||
*/
|
||||
private long cached;
|
||||
@JsonIgnore
|
||||
@Id private UUID uniqueId;
|
||||
|
||||
public CachedPlayer(UUID uniqueId, String trimmedUniqueId, String username, Skin skin, Cape cape, MojangProfile.ProfileProperty[] rawProperties, long cached) {
|
||||
super(uniqueId, trimmedUniqueId, username, skin, cape, rawProperties);
|
||||
this.cached = cached;
|
||||
}
|
||||
/**
|
||||
* The player to cache.
|
||||
*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* The cache information about the request.
|
||||
*/
|
||||
private CacheInformation cache;
|
||||
}
|
@ -6,7 +6,6 @@ import cc.fascinated.model.mojang.MojangProfile;
|
||||
import cc.fascinated.model.skin.Skin;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -16,7 +15,7 @@ public class Player {
|
||||
/**
|
||||
* The UUID of the player
|
||||
*/
|
||||
@Id private final UUID uniqueId;
|
||||
private final UUID uniqueId;
|
||||
|
||||
/**
|
||||
* The trimmed UUID of the player
|
||||
|
Reference in New Issue
Block a user