Created
February 7, 2013 04:17
-
-
Save msarchet/4728459 to your computer and use it in GitHub Desktop.
Cleanly update an item in a ServiceStack.Redis.IRedisList<T>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sometimes you need to just udpate something and assure that it happens | |
*/ | |
public static class GenericReplaceLock | |
{ | |
public static void Replace<T>(this IRedisClient Client, string key, T old, T newer) | |
{ | |
using (var redis = Client.As<T>()) | |
using (var transaction = redis.CreateTransaction()) | |
{ | |
transaction.QueueCommand(r => r.Lists[key].Remove(old)); | |
transaction.QueueCommand(r => r.Lists[key].Add(newer)); | |
transaction.Commit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment