当前位置: 首页>>代码示例>>C#>>正文


C# IRedisClient.CreateTransaction方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:22,代码来源:RedisServerEvents.cs

示例2: UseTransaction

 private void UseTransaction(IRedisClient client, Action<IRedisTransaction> action)
 {
     using (var transaction = client.CreateTransaction())
     {
         action(transaction);
         transaction.Commit();
     }
 }
开发者ID:kerryyao,项目名称:Harbour.RedisSessionStateStore,代码行数:8,代码来源:RedisSessionStateStoreProvider.cs

示例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();
			}
		}
开发者ID:kevinpriester,项目名称:EktronContrib,代码行数:9,代码来源:RedisSessionStateStore.cs

示例4: Commit

 private static void Commit(IRedisClient redis, Action<RedisWriteOnlyTransaction> action)
 {
     using (var transaction = new RedisWriteOnlyTransaction(redis.CreateTransaction()))
     {
         action(transaction);
         transaction.Commit();
     }
 }
开发者ID:atonse,项目名称:Hangfire,代码行数:8,代码来源:RedisWriteOnlyTransactionFacts.cs

示例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();
            }
        }
开发者ID:atonse,项目名称:Hangfire,代码行数:15,代码来源:RedisConnection.cs

示例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();
            }
        }
开发者ID:hahmed,项目名称:HangFire,代码行数:22,代码来源:RedisConnection.cs

示例7: GetRedisTransaction

            private IRedisTransaction GetRedisTransaction()
            {
                if (redisTransaction != null)
                    return redisTransaction;

                redisClient = new RedisClient(destination.Server);
				redisTransaction = redisClient.CreateTransaction();

                return redisTransaction;
            }
开发者ID:pacoweb,项目名称:ravendb,代码行数:10,代码来源:IndexReplicationToRedisIndexUpdateTrigger.cs

示例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();
            }
        }
开发者ID:kevinpriester,项目名称:EktronContrib,代码行数:14,代码来源:RedisCachingProvider.cs


注:本文中的IRedisClient.CreateTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。