mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 20:17:22 +01:00
remove semaphore
This commit is contained in:
parent
097d7d16e9
commit
18a9a76dcd
1 changed files with 1 additions and 14 deletions
|
|
@ -20,7 +20,6 @@ public class MareConfigurationServiceClient<T> : IConfigurationService<T> where
|
|||
private readonly ILogger<MareConfigurationServiceClient<T>> _logger;
|
||||
private readonly GrpcClientFactory _grpcClientFactory;
|
||||
private readonly string _grpcClientName;
|
||||
private static readonly SemaphoreSlim _readLock = new(1);
|
||||
|
||||
public MareConfigurationServiceClient(ILogger<MareConfigurationServiceClient<T>> logger, IOptions<T> config, GrpcClientFactory grpcClientFactory, string grpcClientName)
|
||||
{
|
||||
|
|
@ -40,10 +39,8 @@ public class MareConfigurationServiceClient<T> : IConfigurationService<T> where
|
|||
bool isRemote = prop.GetCustomAttributes(typeof(RemoteConfigurationAttribute), inherit: true).Any();
|
||||
if (isRemote)
|
||||
{
|
||||
_readLock.Wait();
|
||||
if (_cachedRemoteProperties.TryGetValue(key, out var existingEntry))
|
||||
{
|
||||
_readLock.Release();
|
||||
return (T1)_cachedRemoteProperties[key].Value;
|
||||
}
|
||||
|
||||
|
|
@ -67,10 +64,6 @@ public class MareConfigurationServiceClient<T> : IConfigurationService<T> where
|
|||
return defaultValue;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_readLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
var value = prop.GetValue(_config);
|
||||
|
|
@ -103,10 +96,8 @@ public class MareConfigurationServiceClient<T> : IConfigurationService<T> where
|
|||
bool isRemote = prop.GetCustomAttributes(typeof(RemoteConfigurationAttribute), inherit: true).Any();
|
||||
if (isRemote)
|
||||
{
|
||||
_readLock.Wait();
|
||||
if (_cachedRemoteProperties.TryGetValue(key, out var existingEntry) && existingEntry.Inserted > DateTime.Now - TimeSpan.FromMinutes(60))
|
||||
if (_cachedRemoteProperties.TryGetValue(key, out var existingEntry))
|
||||
{
|
||||
_readLock.Release();
|
||||
return (T1)_cachedRemoteProperties[key].Value;
|
||||
}
|
||||
|
||||
|
|
@ -130,10 +121,6 @@ public class MareConfigurationServiceClient<T> : IConfigurationService<T> where
|
|||
throw new KeyNotFoundException(key);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_readLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
var value = prop.GetValue(_config);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue