cache network data longer

release-10.1.0
Luke Pulverenti 7 years ago
parent 39f20fdb4e
commit 26edcfefbb

@ -19,10 +19,43 @@ namespace Emby.Server.Implementations.Networking
{
protected ILogger Logger { get; private set; }
private DateTime _lastRefresh;
private int NetworkCacheMinutes = 360;
public NetworkManager(ILogger logger)
{
Logger = logger;
try
{
NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
}
catch (Exception ex)
{
NetworkCacheMinutes = 15;
Logger.ErrorException("Error binding to NetworkAddressChanged event", ex);
}
try
{
NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
}
catch (Exception ex)
{
NetworkCacheMinutes = 15;
Logger.ErrorException("Error binding to NetworkChange_NetworkAvailabilityChanged event", ex);
}
}
private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
Logger.Debug("NetworkAvailabilityChanged");
_lastRefresh = DateTime.MinValue;
}
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
{
Logger.Debug("NetworkAddressChanged");
_lastRefresh = DateTime.MinValue;
}
private List<IpAddressInfo> _localIpAddresses;
@ -30,11 +63,9 @@ namespace Emby.Server.Implementations.Networking
public List<IpAddressInfo> GetLocalIpAddresses()
{
const int cacheMinutes = 10;
lock (_localIpAddressSyncLock)
{
var forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= cacheMinutes;
var forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= NetworkCacheMinutes;
if (_localIpAddresses == null || forceRefresh)
{

@ -393,6 +393,10 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return "wmav2";
}
if (string.Equals(codec, "opus", StringComparison.OrdinalIgnoreCase))
{
return "libopus";
}
return codec.ToLower();
}

@ -1,3 +1,3 @@
using System.Reflection;
[assembly: AssemblyVersion("3.2.40.3")]
[assembly: AssemblyVersion("3.2.40.4")]

Loading…
Cancel
Save