Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Enyim.Caching/Enyim.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<RepositoryUrl>https://github.com/cnblogs/EnyimMemcachedCore</RepositoryUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<Version>2.4.0-beta2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
25 changes: 14 additions & 11 deletions Enyim.Caching/Memcached/MemcachedNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MemcachedNode : IMemcachedNode

private bool isDisposed;

private readonly EndPoint endPoint;
private readonly EndPoint _endPoint;
private readonly ISocketPoolConfiguration config;
private InternalPoolImpl internalPoolImpl;
private bool isInitialized = false;
Expand All @@ -40,7 +40,8 @@ public MemcachedNode(
ISocketPoolConfiguration socketPoolConfig,
ILogger logger)
{
this.endPoint = endpoint;
_endPoint = endpoint;
EndPointString = endpoint?.ToString().Replace("Unspecified/", string.Empty);
this.config = socketPoolConfig;

if (socketPoolConfig.ConnectionTimeout.TotalMilliseconds >= Int32.MaxValue)
Expand Down Expand Up @@ -72,9 +73,11 @@ protected INodeFailurePolicy FailurePolicy
/// </summary>
public EndPoint EndPoint
{
get { return this.endPoint; }
get { return _endPoint; }
}

public string EndPointString { get; private set; }

/// <summary>
/// <para>Gets a value indicating whether the server is working or not. Returns a <b>cached</b> state.</para>
/// <para>To get real-time information and update the cached state, use the <see cref="M:Ping"/> method.</para>
Expand Down Expand Up @@ -771,7 +774,7 @@ protected internal virtual PooledSocket CreateSocket()
{
try
{
var ps = new PooledSocket(this.endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger);
var ps = new PooledSocket(_endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger);
ps.Connect();
return ps;
}
Expand All @@ -787,13 +790,13 @@ protected internal virtual async Task<PooledSocket> CreateSocketAsync()
{
try
{
var ps = new PooledSocket(this.endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger);
var ps = new PooledSocket(_endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger);
await ps.ConnectAsync();
return ps;
}
catch (Exception ex)
{
var endPointStr = endPoint.ToString().Replace("Unspecified/", string.Empty);
var endPointStr = _endPoint.ToString().Replace("Unspecified/", string.Empty);
_logger.LogError(ex, $"Failed to {nameof(CreateSocketAsync)} to {endPointStr}");
throw;
}
Expand Down Expand Up @@ -835,7 +838,7 @@ protected virtual IPooledSocketResult ExecuteOperation(IOperation op)
}
catch (IOException e)
{
_logger.LogError(nameof(MemcachedNode), e);
_logger.LogError(e, $"Failed to ExecuteOperation on {EndPointString}");

result.Fail("Exception reading response", e);
return result;
Expand Down Expand Up @@ -887,14 +890,14 @@ protected virtual async Task<IPooledSocketResult> ExecuteOperationAsync(IOperati
}
catch (IOException e)
{
_logger.LogError(nameof(MemcachedNode), e);
_logger.LogError(e, $"IOException occurs when ExecuteOperationAsync({op}) on {EndPointString}");

result.Fail("IOException reading response", e);
return result;
}
catch (SocketException e)
{
_logger.LogError(nameof(MemcachedNode), e);
_logger.LogError(e, $"SocketException occurs when ExecuteOperationAsync({op}) on {EndPointString}");

result.Fail("SocketException reading response", e);
return result;
Expand Down Expand Up @@ -936,7 +939,7 @@ protected virtual async Task<bool> ExecuteOperationAsync(IOperation op, Action<b
}
catch (IOException e)
{
_logger.LogError(nameof(MemcachedNode), e);
_logger.LogError(e, $"Failed to ExecuteOperationAsync({op}) with next action on {EndPointString}");
((IDisposable)socket).Dispose();

return false;
Expand All @@ -956,7 +959,7 @@ private void LogExecutionTime(string title, DateTime startTime, int thresholdMs)

EndPoint IMemcachedNode.EndPoint
{
get { return this.EndPoint; }
get { return _endPoint; }
}

bool IMemcachedNode.IsAlive
Expand Down