本文整理汇总了C#中IRedisClient.CreateTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# IRedisClient.CreateTransaction方法的具体用法?C# IRedisClient.CreateTransaction怎么用?C# IRedisClient.CreateTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRedisClient
的用法示例。
在下文中一共展示了IRedisClient.CreateTransaction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreSubscriptionInfo
private void StoreSubscriptionInfo(IRedisClient redis, SubscriptionInfo info)
{
var id = info.SubscriptionId;
using (var trans = redis.CreateTransaction())
{
trans.QueueCommand(r => r.AddItemToSortedSet(RedisIndex.ActiveSubscriptionsSet, id, RedisPubSub.CurrentServerTime.Ticks));
trans.QueueCommand(r => r.Set(RedisIndex.Subscription.Fmt(id), info));
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.UserIdSet.Fmt(info.UserId), id));
foreach (var channel in info.Channels)
{
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.ChannelSet.Fmt(channel), id));
}
if (info.UserName != null)
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.UserNameSet.Fmt(info.UserName), id));
if (info.SessionId != null)
trans.QueueCommand(r => r.AddItemToSet(RedisIndex.SessionSet.Fmt(info.SessionId), id));
trans.Commit();
}
}
示例2: UseTransaction
private void UseTransaction(IRedisClient client, Action<IRedisTransaction> action)
{
using (var transaction = client.CreateTransaction())
{
action(transaction);
transaction.Commit();
}
}
示例3: UpdateSessionState
private void UpdateSessionState(IRedisClient client, string key, RedisSessionState state)
{
using (var t = client.CreateTransaction())
{
t.QueueCommand(c => c.SetRangeInHashRaw(key, state.ToMap()));
t.QueueCommand(c => c.ExpireEntryIn(key, TimeSpan.FromMinutes(state.Timeout)));
t.Commit();
}
}
示例4: Commit
private static void Commit(IRedisClient redis, Action<RedisWriteOnlyTransaction> action)
{
using (var transaction = new RedisWriteOnlyTransaction(redis.CreateTransaction()))
{
action(transaction);
transaction.Commit();
}
}
示例5: RemoveServer
public static void RemoveServer(IRedisClient redis, string serverId)
{
using (var transaction = redis.CreateTransaction())
{
transaction.QueueCommand(x => x.RemoveItemFromSet(
RedisStorage.Prefix + "servers",
serverId));
transaction.QueueCommand(x => x.RemoveEntry(
String.Format(RedisStorage.Prefix + "server:{0}", serverId),
String.Format(RedisStorage.Prefix + "server:{0}:queues", serverId)));
transaction.Commit();
}
}
示例6: RemoveFromFetchedList
public static void RemoveFromFetchedList(
IRedisClient redis,
string queue,
string jobId)
{
using (var transaction = redis.CreateTransaction())
{
transaction.QueueCommand(x => x.RemoveItemFromList(
String.Format(RedisStorage.Prefix + "queue:{0}:dequeued", queue),
jobId,
-1));
transaction.QueueCommand(x => x.RemoveEntryFromHash(
String.Format(RedisStorage.Prefix + "job:{0}", jobId),
"Fetched"));
transaction.QueueCommand(x => x.RemoveEntryFromHash(
String.Format(RedisStorage.Prefix + "job:{0}", jobId),
"Checked"));
transaction.Commit();
}
}
示例7: GetRedisTransaction
private IRedisTransaction GetRedisTransaction()
{
if (redisTransaction != null)
return redisTransaction;
redisClient = new RedisClient(destination.Server);
redisTransaction = redisClient.CreateTransaction();
return redisTransaction;
}
示例8: TransactionalAdd
private void TransactionalAdd(IRedisClient client, string key, CacheItem cacheItem, TimeSpan timeSpanExpiration)
{
if (client.ContainsKey(key)) throw new KeyAlreadyExistsException();
using (var trans = client.CreateTransaction())
{
trans.QueueCommand(r => r.Set(key, cacheItem));
if (timeSpanExpiration != TimeSpan.Zero)
trans.QueueCommand(r => r.ExpireEntryIn(key, timeSpanExpiration));
trans.Commit();
}
}