Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated Execute method of IMemcachedNode to return IOperationResult.

  • Loading branch information...
commit 5f1adc50ea8ef31ab23740edeb019f2eeec6b1bc 1 parent 2162ebd
John Zablocki johnzablocki authored
1  Enyim.Caching.Tests/MemcachedClientTestsBase.cs
View
@@ -75,6 +75,7 @@ protected void StoreAssertFail(IStoreOperationResult result)
Assert.That(result.Success, Is.False, "Success was true");
Assert.That(result.Cas, Is.EqualTo(0), "Cas value was not 0");
Assert.That(result.StatusCode, Is.GreaterThan(0), "StatusCode not greater than 0");
+ Assert.That(result.InnerResult, Is.Not.Null, "InnerResult was null");
}
protected void GetAssertPass(IGetOperationResult result, object expectedValue)
3  Enyim.Caching/Memcached/IMemcachedNode.cs
View
@@ -2,6 +2,7 @@
using System.Net;
using System.Collections.Generic;
using Enyim.Caching.Memcached.Protocol;
+using Enyim.Caching.Memcached.Results;
namespace Enyim.Caching.Memcached
{
@@ -11,7 +12,7 @@ public interface IMemcachedNode : IDisposable
bool IsAlive { get; }
bool Ping();
- bool Execute(IOperation op);
+ IOperationResult Execute(IOperation op);
bool ExecuteAsync(IOperation op, Action<bool> next);
// PooledSocket CreateSocket(TimeSpan connectionTimeout, TimeSpan receiveTimeout);
4 Enyim.Caching/Memcached/MemcachedNode.cs
View
@@ -600,9 +600,9 @@ bool IMemcachedNode.Ping()
return this.Ping();
}
- bool IMemcachedNode.Execute(IOperation op)
+ IOperationResult IMemcachedNode.Execute(IOperation op)
{
- return this.ExecuteOperation(op).Success;
+ return this.ExecuteOperation(op);
}
bool IMemcachedNode.ExecuteAsync(IOperation op, Action<bool> next)
5 Enyim.Caching/MemcachedClient.Results.cs
View
@@ -450,14 +450,15 @@ public IRemoveOperationResult ExecuteRemove(string key)
if (node != null)
{
var command = this.pool.OperationFactory.Delete(hashedKey, 0);
- var success = node.Execute(command);
+ var commandResult = node.Execute(command);
- if (success)
+ if (commandResult.Success)
{
result.Pass();
}
else
{
+ result.InnerResult = commandResult;
result.Fail("Failed to remove item, see InnerResult or StatusCode for details");
}
39 Enyim.Caching/MemcachedClient.cs
View
@@ -185,8 +185,9 @@ protected virtual IGetOperationResult PerformTryGet(string key, out ulong cas, o
if (node != null)
{
var command = this.pool.OperationFactory.Get(hashedKey);
+ var commandResult = node.Execute(command);
- if (node.Execute(command))
+ if (commandResult.Success)
{
result.Value = value = this.transcoder.Deserialize(command.Result);
result.Cas = cas = command.CasValue;
@@ -200,6 +201,7 @@ protected virtual IGetOperationResult PerformTryGet(string key, out ulong cas, o
{
result.Value = value = null;
result.Cas = cas = 0;
+ result.InnerResult = commandResult;
result.Fail("Get operation failed. See InnerResult or StatusCode for details");
return result;
}
@@ -362,18 +364,19 @@ protected virtual IStoreOperationResult PerformStore(StoreMode mode, string key,
}
var command = this.pool.OperationFactory.Store(mode, hashedKey, item, expires, cas);
- var retval = node.Execute(command);
+ var commandResult = node.Execute(command);
result.Cas = cas = command.CasValue;
result.StatusCode = statusCode = command.StatusCode;
- if (retval)
+ if (commandResult.Success)
{
if (this.performanceMonitor != null) this.performanceMonitor.Store(mode, 1, true);
result.Pass();
return result;
}
+ result.InnerResult = commandResult;
result.Fail("Store operation failed, see InnerResult or StatusCode for details");
return result;
}
@@ -593,14 +596,14 @@ protected virtual IMutateOperationResult PerformMutate(MutationMode mode, string
if (node != null)
{
var command = this.pool.OperationFactory.Mutate(mode, hashedKey, defaultValue, delta, expires, cas);
- var success = node.Execute(command);
+ var commandResult = node.Execute(command);
result.Cas = cas = command.CasValue;
result.StatusCode = command.StatusCode;
- if (success)
+ if (commandResult.Success)
{
- if (this.performanceMonitor != null) this.performanceMonitor.Mutate(mode, 1, success);
+ if (this.performanceMonitor != null) this.performanceMonitor.Mutate(mode, 1, commandResult.Success);
result.Value = command.Result;
result.Pass();
return result;
@@ -608,6 +611,7 @@ protected virtual IMutateOperationResult PerformMutate(MutationMode mode, string
else
{
if (this.performanceMonitor != null) this.performanceMonitor.Mutate(mode, 1, false);
+ result.InnerResult = commandResult;
result.Fail("Mutate operation failed, see InnerResult or StatusCode for more details");
}
@@ -687,9 +691,9 @@ protected virtual IConcatOperationResult PerformConcatenate(ConcatenationMode mo
if (node != null)
{
var command = this.pool.OperationFactory.Concat(mode, hashedKey, cas, data);
- var retval = node.Execute(command);
+ var commandResult = node.Execute(command);
- if (retval)
+ if (commandResult.Success)
{
result.Cas = cas = command.CasValue;
result.StatusCode = command.StatusCode;
@@ -698,6 +702,7 @@ protected virtual IConcatOperationResult PerformConcatenate(ConcatenationMode mo
}
else
{
+ result.InnerResult = commandResult;
result.Fail("Concat operation failed, see InnerResult or StatusCode for details");
}
@@ -742,7 +747,7 @@ public ServerStats Stats(string type)
foreach (var node in this.pool.GetWorkingNodes())
{
var cmd = this.pool.OperationFactory.Stats(type);
- var action = new Func<IOperation, bool>(node.Execute);
+ var action = new Func<IOperation, IOperationResult>(node.Execute);
var mre = new ManualResetEvent(false);
handles.Add(mre);
@@ -776,17 +781,7 @@ public ServerStats Stats(string type)
/// <returns>true if the item was successfully removed from the cache; false otherwise.</returns>
public bool Remove(string key)
{
- var hashedKey = this.keyTransformer.Transform(key);
- var node = this.pool.Locate(hashedKey);
-
- if (node != null)
- {
- var command = this.pool.OperationFactory.Delete(hashedKey, 0);
-
- return node.Execute(command);
- }
-
- return false;
+ return ExecuteRemove(key).Success;
}
/// <summary>
@@ -829,7 +824,7 @@ public bool Remove(string key)
var mget = this.pool.OperationFactory.MultiGet(nodeKeys);
// we'll use the delegate's BeginInvoke/EndInvoke to run the gets parallel
- var action = new Func<IOperation, bool>(node.Execute);
+ var action = new Func<IOperation, IOperationResult>(node.Execute);
var mre = new ManualResetEvent(false);
handles.Add(mre);
@@ -839,7 +834,7 @@ public bool Remove(string key)
try
{
using (iar.AsyncWaitHandle)
- if (action.EndInvoke(iar))
+ if (action.EndInvoke(iar).Success)
{
#region perfmon
if (this.performanceMonitor != null)
Please sign in to comment.
Something went wrong with that request. Please try again.