Skip to content
Browse files

Fix Increment call that takes a CAS parameter

Possible fix for http://support.couchbase.com/requests/2380
Handle scenario where the object that returns from CasMutate has a null StatusCode property
  • Loading branch information...
1 parent f3bb897 commit 4500dc4d5563b16e21e4ba8007e642da022b8d4b @AndrewLane AndrewLane committed Dec 21, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 Enyim.Caching/MemcachedClient.cs
View
12 Enyim.Caching/MemcachedClient.cs
@@ -444,7 +444,7 @@ public ulong Increment(string key, ulong defaultValue, ulong delta, DateTime exp
public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, ulong cas)
{
var result = this.CasMutate(MutationMode.Increment, key, defaultValue, delta, 0, cas);
- return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode.Value };
+ return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode == null ? default(int) : result.StatusCode.Value };
}
/// <summary>
@@ -460,7 +460,7 @@ public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, u
public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas)
{
var result = this.CasMutate(MutationMode.Increment, key, defaultValue, delta, MemcachedClient.GetExpiration(validFor, null), cas);
- return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode.Value };
+ return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode == null ? default(int) : result.StatusCode.Value };
}
/// <summary>
@@ -476,7 +476,7 @@ public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, T
public CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, DateTime expiresAt, ulong cas)
{
var result = this.CasMutate(MutationMode.Increment, key, defaultValue, delta, MemcachedClient.GetExpiration(null, expiresAt), cas);
- return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode.Value };
+ return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode == null ? default(int) : result.StatusCode.Value };
}
#endregion
@@ -534,7 +534,7 @@ public ulong Decrement(string key, ulong defaultValue, ulong delta, DateTime exp
public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, ulong cas)
{
var result = this.CasMutate(MutationMode.Decrement, key, defaultValue, delta, 0, cas);
- return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode.Value };
+ return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode == null ? default(int) : result.StatusCode.Value };
}
/// <summary>
@@ -550,7 +550,7 @@ public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, u
public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas)
{
var result = this.CasMutate(MutationMode.Decrement, key, defaultValue, delta, MemcachedClient.GetExpiration(validFor, null), cas);
- return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode.Value };
+ return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode == null ? default(int) : result.StatusCode.Value };
}
/// <summary>
@@ -566,7 +566,7 @@ public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, T
public CasResult<ulong> Decrement(string key, ulong defaultValue, ulong delta, DateTime expiresAt, ulong cas)
{
var result = this.CasMutate(MutationMode.Decrement, key, defaultValue, delta, MemcachedClient.GetExpiration(null, expiresAt), cas);
- return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode.Value };
+ return new CasResult<ulong> { Cas = result.Cas, Result = result.Value, StatusCode = result.StatusCode == null ? default(int) : result.StatusCode.Value };
}
#endregion

0 comments on commit 4500dc4

Please sign in to comment.
Something went wrong with that request. Please try again.