forked from Fascinated/Bat
update cache expiration policy
This commit is contained in:
parent
04c4533c40
commit
7a1ffc0538
@ -49,8 +49,8 @@ public class GuildListener implements EventListener {
|
||||
"<#%s>".formatted(expandedInvite.getChannel().getId()) : expandedInvite.getChannel().getName()
|
||||
), true);
|
||||
}
|
||||
description.appendLine("Max Uses: `%s`".formatted(expandedInvite.getMaxUses() == 0 ? "Infinite" : expandedInvite.getMaxUses()), true);
|
||||
description.appendLine("Creator: %s".formatted(expandedInvite.getInviter() == null ? "Unknown" : expandedInvite.getInviter().getAsMention()), true);
|
||||
description.appendLine("Max Uses: `%s`".formatted(expandedInvite.getMaxUses() == 0 ? "Infinite" : expandedInvite.getMaxUses()), true);
|
||||
;
|
||||
logFeature.sendLog(guild, LogType.INVITE_CREATE, EmbedUtils.successEmbed().setDescription(description.build()).build());
|
||||
});
|
||||
|
@ -18,7 +18,7 @@ public class UserFeedCommand extends BatCommand {
|
||||
super.addSubCommands(
|
||||
context.getBean(UserSubCommand.class),
|
||||
context.getBean(ChannelSubCommand.class),
|
||||
context.getBean(ResetSubCommand.class
|
||||
));
|
||||
context.getBean(ResetSubCommand.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,11 @@ import org.springframework.stereotype.Component;
|
||||
@Component("scoresaber-user-feed:user.sub")
|
||||
@CommandInfo(name = "user", description = "Adds or removes a user from the feed")
|
||||
public class UserSubCommand extends BatCommand {
|
||||
private final GuildService guildService;
|
||||
private final UserService userService;
|
||||
|
||||
@Autowired
|
||||
public UserSubCommand(GuildService guildService, UserService userService) {
|
||||
public UserSubCommand(UserService userService) {
|
||||
super.addOptions(new OptionData(OptionType.USER, "user", "Add or remove a user from the score feed", false));
|
||||
this.guildService = guildService;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import lombok.extern.log4j.Log4j2;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateGlobalNameEvent;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -36,6 +37,7 @@ public class UserService implements EventListener {
|
||||
*/
|
||||
private final Map<String, BatUser> users = ExpiringMap.builder()
|
||||
.expiration(1, TimeUnit.HOURS)
|
||||
.expirationPolicy(ExpirationPolicy.ACCESSED) // Expire after not being accessed for 1 hour
|
||||
.expirationListener((key, cachedUser) -> {
|
||||
BatUser user = (BatUser) cachedUser;
|
||||
log.info("Removed user \"{}\" - \"{}\" from cache", user.getName(), user.getId());
|
||||
|
Loading…
Reference in New Issue
Block a user