clean up cache info
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:
parent
c198339acc
commit
8216ec7943
@ -8,25 +8,27 @@ import org.springframework.data.redis.core.RedisHash;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor @Setter @Getter @ToString
|
||||
@Setter @Getter @ToString
|
||||
@NoArgsConstructor
|
||||
@RedisHash(value = "mojangEndpointStatus", timeToLive = 60L) // 1 minute (in seconds)
|
||||
public final class CachedEndpointStatus implements Serializable {
|
||||
public final class CachedEndpointStatus extends CachedResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* The id for this endpoint cache.
|
||||
*/
|
||||
@Id @NonNull @JsonIgnore
|
||||
private final String id;
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The list of endpoints and their status.
|
||||
*/
|
||||
private final Map<String, Status> endpoints;
|
||||
private Map<String, Status> endpoints;
|
||||
|
||||
/**
|
||||
* The cache information about the request.
|
||||
*/
|
||||
private CacheInformation cache;
|
||||
public CachedEndpointStatus(@NonNull String id, Map<String, Status> endpoints) {
|
||||
super(CacheInformation.defaultCache());
|
||||
this.id = id;
|
||||
this.endpoints = endpoints;
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
/**
|
||||
|
@ -11,23 +11,25 @@ import java.io.Serializable;
|
||||
/**
|
||||
* @author Braydon
|
||||
*/
|
||||
@AllArgsConstructor @Setter @Getter @ToString
|
||||
@Setter @Getter @ToString
|
||||
@NoArgsConstructor
|
||||
@RedisHash(value = "server", timeToLive = 60L) // 1 minute (in seconds)
|
||||
public final class CachedMinecraftServer implements Serializable {
|
||||
public final class CachedMinecraftServer extends CachedResponse implements Serializable {
|
||||
/**
|
||||
* The id of this cached server.
|
||||
*/
|
||||
@Id @NonNull @JsonIgnore
|
||||
private final String id;
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The cached server.
|
||||
*/
|
||||
@NonNull
|
||||
private final MinecraftServer server;
|
||||
private MinecraftServer server;
|
||||
|
||||
/**
|
||||
* The cache information about the request.
|
||||
*/
|
||||
private CacheInformation cache;
|
||||
public CachedMinecraftServer(@NonNull String id, @NonNull MinecraftServer server) {
|
||||
super(CacheInformation.defaultCache());
|
||||
this.id = id;
|
||||
this.server = server;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import cc.fascinated.model.player.Player;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
@ -17,9 +18,9 @@ import java.util.UUID;
|
||||
* @author Braydon
|
||||
*/
|
||||
@Setter @Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@RedisHash(value = "player", timeToLive = 60L * 60L) // 1 hour (in seconds)
|
||||
public final class CachedPlayer implements Serializable {
|
||||
public final class CachedPlayer extends CachedResponse implements Serializable {
|
||||
/**
|
||||
* The unique id of the player.
|
||||
*/
|
||||
@ -31,8 +32,9 @@ public final class CachedPlayer implements Serializable {
|
||||
*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* The cache information about the request.
|
||||
*/
|
||||
private CacheInformation cache;
|
||||
public CachedPlayer(UUID uniqueId, Player player) {
|
||||
super(CacheInformation.defaultCache());
|
||||
this.uniqueId = uniqueId;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
15
src/main/java/cc/fascinated/model/cache/CachedResponse.java
vendored
Normal file
15
src/main/java/cc/fascinated/model/cache/CachedResponse.java
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
package cc.fascinated.model.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor @NoArgsConstructor
|
||||
@Getter
|
||||
public class CachedResponse {
|
||||
|
||||
/**
|
||||
* The cache information for this response.
|
||||
*/
|
||||
private CacheInformation cache;
|
||||
}
|
@ -6,26 +6,27 @@ import cc.fascinated.model.mojang.MojangProfile;
|
||||
import cc.fascinated.model.skin.Skin;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter @AllArgsConstructor
|
||||
@Getter @AllArgsConstructor @NoArgsConstructor
|
||||
public class Player {
|
||||
|
||||
/**
|
||||
* The UUID of the player
|
||||
*/
|
||||
private final UUID uniqueId;
|
||||
private UUID uniqueId;
|
||||
|
||||
/**
|
||||
* The trimmed UUID of the player
|
||||
*/
|
||||
private final String trimmedUniqueId;
|
||||
private String trimmedUniqueId;
|
||||
|
||||
/**
|
||||
* The username of the player
|
||||
*/
|
||||
private final String username;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* The skin of the player, null if the
|
||||
|
@ -231,8 +231,7 @@ public class MojangService {
|
||||
log.info("Fetched Mojang API status for {} endpoints", endpoints.size());
|
||||
CachedEndpointStatus status = new CachedEndpointStatus(
|
||||
MOJANG_ENDPOINT_STATUS_KEY,
|
||||
endpoints,
|
||||
CacheInformation.defaultCache()
|
||||
endpoints
|
||||
);
|
||||
mojangEndpointStatusRepository.save(status);
|
||||
status.getCache().setCached(false);
|
||||
|
@ -82,8 +82,7 @@ public class PlayerService {
|
||||
skinAndCape.getLeft(), // Skin
|
||||
skinAndCape.getRight(), // Cape
|
||||
mojangProfile.getProperties() // Raw properties
|
||||
),
|
||||
CacheInformation.defaultCache() // Cache time
|
||||
)
|
||||
);
|
||||
|
||||
playerCacheRepository.save(player);
|
||||
|
@ -89,8 +89,7 @@ public class ServerService {
|
||||
|
||||
CachedMinecraftServer server = new CachedMinecraftServer(
|
||||
key,
|
||||
platform.getPinger().ping(hostname, ip, port, records.toArray(new DNSRecord[0])),
|
||||
CacheInformation.defaultCache()
|
||||
platform.getPinger().ping(hostname, ip, port, records.toArray(new DNSRecord[0]))
|
||||
);
|
||||
|
||||
// Check if the server is blocked by Mojang
|
||||
|
Loading…
Reference in New Issue
Block a user