Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NCBC-229: Add Remove with Cas method

  • Loading branch information...
commit e3c4fa28a12ef89a19a542a64849478411d59f44 1 parent 4388f4c
@johnzablocki johnzablocki authored
View
1  Enyim.Caching/IMemcachedClient.cs
@@ -49,6 +49,7 @@ public interface IMemcachedClient : IDisposable
CasResult<ulong> Increment(string key, ulong defaultValue, ulong delta, TimeSpan validFor, ulong cas);
bool Remove(string key);
+ bool Remove(string key, ulong cas);
void FlushAll();
View
1  Enyim.Caching/IMemcachedResultsClient.cs
@@ -50,6 +50,7 @@ public interface IMemcachedResultsClient
IConcatOperationResult ExecutePrepend(string key, ulong cas, ArraySegment<byte> data);
IRemoveOperationResult ExecuteRemove(string key);
+ IRemoveOperationResult ExecuteRemove(string key, ulong cas);
}
}
View
3  Enyim.Caching/Memcached/Results/StatusCodes/StatusCodeEnums.cs
@@ -8,7 +8,8 @@ namespace Enyim.Caching.Memcached.Results.StatusCodes
public enum StatusCodeEnums
{
Success = 0,
- NotFound
+ NotFound,
+ DataExistsForKey
}
}
View
12 Enyim.Caching/MemcachedClient.Results.cs
@@ -441,15 +441,25 @@ public IConcatOperationResult ExecutePrepend(string key, ulong cas, ArraySegment
/// </summary>
/// <param name="key">The identifier for the item to delete.</param>
/// <returns>true if the item was successfully removed from the cache; false otherwise.</returns>
+ public IRemoveOperationResult ExecuteRemove(string key, ulong cas)
+ {
+ return PerformRemove(key, cas);
+ }
+
public IRemoveOperationResult ExecuteRemove(string key)
{
+ return PerformRemove(key);
+ }
+
+ protected IRemoveOperationResult PerformRemove(string key, ulong cas = 0)
+ {
var hashedKey = this.keyTransformer.Transform(key);
var node = this.pool.Locate(hashedKey);
var result = RemoveOperationResultFactory.Create();
if (node != null)
{
- var command = this.pool.OperationFactory.Delete(hashedKey, 0);
+ var command = this.pool.OperationFactory.Delete(hashedKey, cas);
var commandResult = node.Execute(command);
if (commandResult.Success)
View
11 Enyim.Caching/MemcachedClient.cs
@@ -784,6 +784,17 @@ public bool Remove(string key)
}
/// <summary>
+ /// Removes the specified item from the cache.
+ /// </summary>
+ /// <param name="key">The identifier for the item to delete.</param>
+ /// <param name="cas">The Cas value associated with the key</param>
+ /// <returns>true if the item was successfully removed from the cache; false otherwise.</returns>
+ public bool Remove(string key, ulong cas)
+ {
+ return ExecuteRemove(key, cas).Success;
+ }
+
+ /// <summary>
/// Retrieves multiple items from the cache.
/// </summary>
/// <param name="keys">The list of identifiers for the items to retrieve.</param>
Please sign in to comment.
Something went wrong with that request. Please try again.