[Fix] Clamp cache size (#3038)
* fix * clamp max cache size * net 4.6.1 strikes again * real
This commit is contained in:
@@ -18,8 +18,13 @@ internal class AuditLogCache
|
||||
public AuditLogCache(DiscordSocketClient client)
|
||||
{
|
||||
_size = client.AuditLogCacheSize;
|
||||
var dictSize = _size;
|
||||
if (dictSize * 1.05 > int.MaxValue)
|
||||
dictSize = int.MaxValue;
|
||||
else
|
||||
dictSize = (int)(dictSize * 1.05);
|
||||
|
||||
_entries = new ConcurrentDictionary<ulong, SocketAuditLogEntry>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(_size * 1.05));
|
||||
_entries = new ConcurrentDictionary<ulong, SocketAuditLogEntry>(ConcurrentHashSet.DefaultConcurrencyLevel, dictSize);
|
||||
_orderedEntries = new ConcurrentQueue<ulong>();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,12 @@ namespace Discord.WebSocket
|
||||
public MessageCache(DiscordSocketClient discord)
|
||||
{
|
||||
_size = discord.MessageCacheSize;
|
||||
_messages = new ConcurrentDictionary<ulong, SocketMessage>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(_size * 1.05));
|
||||
var dictSize = _size;
|
||||
if (dictSize * 1.05 > int.MaxValue)
|
||||
dictSize = int.MaxValue;
|
||||
else
|
||||
dictSize = (int)(dictSize * 1.05);
|
||||
_messages = new ConcurrentDictionary<ulong, SocketMessage>(ConcurrentHashSet.DefaultConcurrencyLevel, dictSize);
|
||||
_orderedMessages = new ConcurrentQueue<ulong>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user