mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-07 19:40:23 +01:00
Add scaling object cap for usermap, prevent huge memory usage, also config file configurable.
This commit is contained in:
parent
bf675b230e
commit
e8d9951ee8
@ -146,7 +146,7 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
@ -184,15 +184,17 @@ public interface ISettings extends IConf
|
||||
|
||||
double getMaxWalkSpeed();
|
||||
|
||||
public int getMailsPerMinute();
|
||||
int getMailsPerMinute();
|
||||
|
||||
public long getEconomyLagWarning();
|
||||
long getEconomyLagWarning();
|
||||
|
||||
public void setEssentialsChatActive(boolean b);
|
||||
void setEssentialsChatActive(boolean b);
|
||||
|
||||
long getMaxTempban();
|
||||
|
||||
public Map<String, Object> getListGroupConfig();
|
||||
Map<String, Object> getListGroupConfig();
|
||||
|
||||
public int getMaxNickLength();
|
||||
int getMaxNickLength();
|
||||
|
||||
int getMaxUserCacheCount();
|
||||
}
|
||||
|
@ -1105,4 +1105,11 @@ public class Settings implements net.ess3.api.ISettings
|
||||
{
|
||||
return config.getInt("max-nick-length", 30);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxUserCacheCount()
|
||||
{
|
||||
long count = Runtime.getRuntime().maxMemory() / 1024 / 96;
|
||||
return config.getInt("max-user-cache-count", (int)count);
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,14 @@ import org.bukkit.entity.Player;
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this);
|
||||
private final transient Cache<String, User> users;
|
||||
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().build(this);
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user