• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IRedisClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRedisClient的典型用法代码示例。如果您正苦于以下问题:C# IRedisClient类的具体用法?C# IRedisClient怎么用?C# IRedisClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRedisClient类属于命名空间,在下文中一共展示了IRedisClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TrackInstance

        private IRedisClient TrackInstance(MethodBase callingMethodType, string method, IRedisClient instance)
        {
            // track
            var frame = new TrackingFrame()
            {
                Id = Guid.NewGuid(),
                Initialised = DateTime.Now,
                ProvidedToInstanceOfType = callingMethodType.DeclaringType,
            };
            lock (this.trackingFrames)
            {
                this.trackingFrames.Add(frame);
            }

            // proxy
            var proxy = new TrackingRedisClientProxy(instance, frame.Id);
            proxy.BeforeInvoke += (sender, args) =>
            {
                if (string.Compare("Dispose", args.MethodInfo.Name, StringComparison.InvariantCultureIgnoreCase) != 0)
                {
                    return;
                }
                lock (this.trackingFrames)
                {
                    this.trackingFrames.Remove(frame);
                }
                var duration = DateTime.Now - frame.Initialised;

                Logger.DebugFormat("{0,18} Disposed {1} released from instance of type {2} checked out for {3}", method, frame.Id, frame.ProvidedToInstanceOfType.FullName, duration);
            };

            Logger.DebugFormat("{0,18} Tracking {1} allocated to instance of type {2}", method, frame.Id, frame.ProvidedToInstanceOfType.FullName);
            return proxy.GetTransparentProxy() as IRedisClient;
        }
开发者ID:ServiceStack,项目名称:ServiceStack.Redis,代码行数:34,代码来源:TrackingRedisClientsManager.cs


示例2: SetKey

 private void SetKey(IRedisClient client, int count)
 {
     for(int i = 1; i <= count; i++)
     {
         client.Set("key" + i, count);
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:7,代码来源:RedisStreamTests.cs


示例3: DisposableDistributedLock

 /// <summary>
 /// Lock
 /// </summary>
 /// <param name="client"></param>
 /// <param name="globalLockKey"></param>
 /// <param name="acquisitionTimeout">in seconds</param>
 /// <param name="lockTimeout">in seconds</param>
 public DisposableDistributedLock(IRedisClient client, string globalLockKey, int acquisitionTimeout, int lockTimeout)
 {
     myLock = new DistributedLock();
     myClient = client;
     this.globalLockKey = globalLockKey;
     lockState = myLock.Lock(globalLockKey, acquisitionTimeout, lockTimeout, out lockExpire, myClient);
 }
开发者ID:nataren,项目名称:NServiceKit.Redis,代码行数:14,代码来源:DisposableDistributedLock.cs


示例4: FlushRedis

 protected static void FlushRedis(IRedisClient redisClient)
 {
     foreach (var key in redisClient.SearchKeys("recommendify-test*"))
     {
         redisClient.Remove(key);
     }
 }
开发者ID:stormid,项目名称:Recommendify,代码行数:7,代码来源:RecommendifySpecBase.cs


示例5: AssertClientHasHost

        private static void AssertClientHasHost(IRedisClient client, string hostWithOptionalPort)
        {
            var parts = hostWithOptionalPort.Split(':');
            var port = parts.Length > 1 ? int.Parse(parts[1]) : RedisNativeClient.DefaultPort;

            Assert.That(client.Host, Is.EqualTo(parts[0]));
            Assert.That(client.Port, Is.EqualTo(port));
        }
开发者ID:skyfyl,项目名称:ServiceStack.Redis,代码行数:8,代码来源:RedisManagerPoolTests.cs


示例6: GetClient

        public IRedisClient<string> GetClient()
        {
            if (_client == null || _client.IsDisposed || _invalidated)
            _client = new RedisClient(_host, _port);

              _invalidated = false;
              return _client;
        }
开发者ID:johanhelsing,项目名称:sider,代码行数:8,代码来源:ClientsController.cs


示例7: RedisJobFetcher

 public RedisJobFetcher(
     IRedisClient redis, 
     IEnumerable<string> queueNames, 
     TimeSpan fetchTimeout)
 {
     _redis = redis;
     _queueNames = queueNames.ToList();
     _fetchTimeout = fetchTimeout;
 }
开发者ID:hahmed,项目名称:HangFire,代码行数:9,代码来源:RedisJobFetcher.cs


示例8: RedisTempDataProvider

        public RedisTempDataProvider(RedisTempDataProviderOptions options, IRedisClient redis)
        {
            if (options == null) throw new ArgumentNullException("options");
            if (redis == null) throw new ArgumentNullException("redis");

            // Copy so that references can't be modified outside of thsi class.
            this.options = new RedisTempDataProviderOptions(options);
            this.redis = redis;
        }
开发者ID:Keritos,项目名称:Harbour.RedisTempData,代码行数:9,代码来源:RedisTempDataProvider.cs


示例9: Base

 public Base(int maxNeighbours, string redisPrefix, IRedisClient redisClient)
 {
     RedisClient = redisClient;
     MaxNeighbours = maxNeighbours;
     RedisPrefix = redisPrefix;
     InputMatrices = new Dictionary<string, InputMatrix>();
     SimilarityMatrix = new SimilarityMatrix(
             new Options {Key = "similarities", MaxNeighbours = MaxNeighbours, RedisPrefix = RedisPrefix},
             redisClient);
 }
开发者ID:roryf,项目名称:Recommendify,代码行数:10,代码来源:Base.cs


示例10: RedisResultCollection

        public RedisResultCollection(IRedisClient client, string filePrefix)
        {
            this.client = client;
            this.filePrefix = filePrefix;
            this.testRunInfos = new RedisInfoCollection<TestRun>(client, () => new TestRun());

            if(!Directory.Exists(filePrefix))
                Directory.CreateDirectory(filePrefix);

            ForceUnlock();
        }
开发者ID:bizarrefish,项目名称:TestVisor,代码行数:11,代码来源:RedisResultCollection.cs


示例11: LoadBasicStrings

        protected void LoadBasicStrings(IRedisClient redis)
        {
            int A = 'A';
            int Z = 'Z';
            var letters = (Z - A + 1).Times(i => ((char)(i + A)).ToString());
            var numbers = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

            var pos = 0;
            letters.Each(x => redis.Set("string:letters/" + x, x));
            numbers.Each(x => redis.Set("string:numbers/" + pos++, x));
        }
开发者ID:JerryForNet,项目名称:RedisAdminUI,代码行数:11,代码来源:PopulateRedisWithDataService.cs


示例12: RedisBackedFurnaceItemsTestsSetUp

        public void RedisBackedFurnaceItemsTestsSetUp()
        {
            Client = Substitute.For<IRedisClient>();
            ContentTypes = Substitute.For<IFurnaceContentTypes>();
            ContentType = new ContentType { Name = ContentTypeName, Namespace = ContentTypeNamespace };

            SiteConfiguration = Substitute.For<IFurnaceSiteConfiguration>();
            SiteConfiguration.DefaultSiteCulture.Returns(new CultureInfo("en-AU"));

            Sut = new RedisBackedFurnaceItems(Client, SiteConfiguration, ContentTypes);
        }
开发者ID:laurentkempe,项目名称:Furnace,代码行数:11,代码来源:RedisBackedFurnaceItemsTests.cs


示例13: RedisFetchedJob

        public RedisFetchedJob(IRedisClient redis, string jobId, string queue)
        {
            if (redis == null) throw new ArgumentNullException("redis");
            if (jobId == null) throw new ArgumentNullException("jobId");
            if (queue == null) throw new ArgumentNullException("queue");

            _redis = redis;

            JobId = jobId;
            Queue = queue;
        }
开发者ID:atonse,项目名称:Hangfire,代码行数:11,代码来源:RedisFetchedJob.cs


示例14: Execute

        public override void Execute(IRedisClient client)
        {
            try
            {
                if (VoidReturnCommand != null)
                {
                    VoidReturnCommand(client);

                }
                else if (IntReturnCommand != null)
                {
                    IntReturnCommand(client);

                }
                else if (LongReturnCommand != null)
                {
                    LongReturnCommand(client);

                }
                else if (DoubleReturnCommand != null)
                {
                    DoubleReturnCommand(client);

                }
                else if (BytesReturnCommand != null)
                {
                    BytesReturnCommand(client);

                }
                else if (StringReturnCommand != null)
                {
                    StringReturnCommand(client);

                }
                else if (MultiBytesReturnCommand != null)
                {
                    MultiBytesReturnCommand(client);

                }
                else if (MultiStringReturnCommand != null)
                {
                    MultiStringReturnCommand(client);
                }
                else if (DictionaryStringReturnCommand != null)
                {
                    DictionaryStringReturnCommand(client);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
开发者ID:dagangwood163,项目名称:ServiceStack.Redis,代码行数:53,代码来源:RedisCommand.cs


示例15: CCMatrix

 public CCMatrix(Options options, IRedisClient redisClient)
 {
     this.options = options;
     this.redisClient = redisClient;
     Matrix = new SparseMatrix(
             new Options
             {
                 Key = string.Format("{0}:{1}", options.Key, "ccmatrix"),
                 MaxNeighbours = options.MaxNeighbours,
                 RedisPrefix = options.RedisPrefix,
                 Weight = options.Weight
             }, redisClient);
 }
开发者ID:roryf,项目名称:Recommendify,代码行数:13,代码来源:CCMatrix.cs


示例16: ExecOnceOnly

        public ExecOnceOnly(IRedisClientsManager redisManager, string hashKey, string correlationId)
        {
            redisManager.ThrowIfNull("redisManager");
            hashKey.ThrowIfNull("hashKey");

            this.hashKey = hashKey;
            this.correlationId = correlationId;

            if (correlationId != null)
            {
                redis = redisManager.GetClient();
                var exists = !redis.SetEntryInHashIfNotExists(hashKey, correlationId, Flag);
                if (exists)
                    throw HttpError.Conflict("Request {0} has already been processed".Fmt(correlationId));
            }
        }
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:16,代码来源:ExecOnlyOnce.cs


示例17: AppStoresWapUIServiceTest

        public AppStoresWapUIServiceTest()
        {
            _redisServiceMock = new Mock<IRedisService>();
            redisService = _redisServiceMock.Object;

            _redisServiceMock2 = new Mock<IRedisService2>();
            redisService2 = _redisServiceMock2.Object;

            _redisClientMock = new Mock<IRedisClient>();
            redisClient = _redisClientMock.Object;

            _appStoreUIServiceMock = new Mock<IAppStoreUIService>();
            appStoreUIService = _appStoreUIServiceMock.Object;

            _logServiceMock = new Mock<ILogger>();
            logService = _logServiceMock.Object;

            _fileServiceMock = new Mock<IFileService>();
            fileService = _fileServiceMock.Object;

            _fullTextSearchServiceMock = new Mock<IFullTextSearchService>();
            fullTextSearchService = _fullTextSearchServiceMock.Object;

            _requestRepoMock = new Mock<IRequestRepository>();
            requestRepo = _requestRepoMock.Object;

            appStoreUIRealService = new AppStoreUIService(fs, redisReal);

            sesionRepository = new Mock<ISessionRepository>();
            sesionRepositoryReal = new SessionRepository();

            cookieServiceReal =new CookieService();
            cookieService = new Mock<ICookieService>();

            appStoreServiceReal = new AppStoreService(fs, redisReal, appStoreUIRealService, new FullTextSearchService(redisReal),new IMEICacheService(redisReal));
            appStoreServiceReal.RedisService2 = new RedisService2();
            appStoreService = new AppStoreService(fs, redisService, appStoreUIRealService, new FullTextSearchService(redisService), new IMEICacheService(redisReal));
            appStoreService.RedisService2 = redisService2;

            appStoresWapUIServiceReal = new AppStoresWapUISerivces(appStoreUIRealService, redisReal, appStoreServiceReal, sesionRepositoryReal, cookieServiceReal, new FullTextSearchService(redisReal));
            appStoresWapUIServiceReal.RedisService2 = new RedisService2();
            appStoresWapUIService = new AppStoresWapUISerivces(appStoreUIService, redisService, appStoreService, sesionRepository.Object, cookieService.Object, fullTextSearchService);

            appStoresWapUIService.RedisService2 = redisService2;
            Bootstrapper.Start();
            redisReal.FlushAll();
        }
开发者ID:itabas016,项目名称:AppStores,代码行数:47,代码来源:AppStoresWapUIServiceTest.cs


示例18: LoadDifferentKeyTypes

        protected void LoadDifferentKeyTypes(IRedisClient client)
        {
            var items = new List<string> { "one", "two", "three", "four" };
            var map = new Dictionary<string, string> {
                        {"A","one"},
                        {"B","two"},
                        {"C","three"},
                        {"D","four"},
                    };

            items.ForEach(x => Redis.Set("urn:testkeytypes:string:" + x, x));
            items.ForEach(x => Redis.AddItemToList("urn:testkeytypes:list", x));
            items.ForEach(x => Redis.AddItemToSet("urn:testkeytypes:set", x));
            var i = 0;
            items.ForEach(x => Redis.AddItemToSortedSet("urn:testkeytypes:zset", x, i++));
            Redis.SetRangeInHash("urn:testkeytypes:hash", map);
        }
开发者ID:danpak6,项目名称:RedisAdminUI,代码行数:17,代码来源:PopulateRedisWithDataService.cs


示例19: UseClient

		private static void UseClient(IRedisClient client, int clientNo)
		{
			var host = "";

			try
			{
				host = client.Host;

				Debug.WriteLine(String.Format("Client '{0}' is using '{1}'", clientNo, client.Host));
				var differentDbs = new[] { 1, 0, 2 };

				foreach (var db in differentDbs)
				{
					client.Db = db;

					var testClientKey = "test:" + host + ":" + clientNo;
					client.SetEntry(testClientKey, testData);
					var result = client.GetValue(testClientKey) ?? "";
					LogResult(db, testClientKey, result);

					var testClientSetKey = "test+set:" + host + ":" + clientNo;
					client.AddItemToSet(testClientSetKey, testData);
					var resultSet = client.GetAllItemsFromSet(testClientSetKey);
					LogResult(db, testClientKey, resultSet.ToList().FirstOrDefault());

					var testClientListKey = "test+list:" + host + ":" + clientNo;
					client.AddItemToList(testClientListKey, testData);
					var resultList = client.GetAllItemsFromList(testClientListKey);
					LogResult(db, testClientKey, resultList.FirstOrDefault());

				}
			}
			catch (NullReferenceException ex)
			{
				Debug.WriteLine("NullReferenceException StackTrace: \n" + ex.StackTrace);
                Assert.Fail("NullReferenceException");
            }
			catch (Exception ex)
			{
				Debug.WriteLine(String.Format("\t[[email protected]{0}]: {1} => {2}",
					host, ex.GetType().Name, ex));
                Assert.Fail("Exception");
			}
		}
开发者ID:nataren,项目名称:NServiceKit.Redis,代码行数:44,代码来源:RedisRegressionTestRun.cs


示例20: AppStoresServiceTest

        public AppStoresServiceTest()
        {
            _redisServiceMock = new Mock<IRedisService>();
            redisService = _redisServiceMock.Object;

            _redisServiceMock2 = new Mock<IRedisService2>();
            redisService2 = _redisServiceMock2.Object;

            _redisClientMock = new Mock<IRedisClient>();
            redisClient = _redisClientMock.Object;

            _appStoreUIServiceMock = new Mock<IAppStoreUIService>();
            appStoreUIService = _appStoreUIServiceMock.Object;

            _fileServiceMock = new Mock<IFileService>();
            fileService = _fileServiceMock.Object;

            _logServiceMock = new Mock<ILogger>();
            logService = _logServiceMock.Object;

            _requestRepoMock = new Mock<IRequestRepository>();
            requestRepo = _requestRepoMock.Object;

            _fullTextSearchServiceMock = new Mock<IFullTextSearchService>();
            fullTextSearchService = _fullTextSearchServiceMock.Object;
            _imeiCacheServiceMock = new Mock<IIMEICacheService>();
            imeiCacheService = _imeiCacheServiceMock.Object;

            appStoreUIRealService = new AppStoreUIService(fs, redis);
            appStoreUIRealService.RedisService2 = redis2;
            appStoreRealService = new AppStoreService(fs, redis, appStoreUIRealService, fullTextSearchService, imeiCacheService);
            appStoreRealService.RedisService2 = redis2;

            appStoreMockService = new AppStoreService(_fileServiceMock.Object, _redisServiceMock.Object,
                _appStoreUIServiceMock.Object, _fullTextSearchServiceMock.Object,_imeiCacheServiceMock.Object);
            appStoreMockService.RedisService2 = redisService2;
            redis.FlushAll();

            EntityMapping.Config();
        }
开发者ID:itabas016,项目名称:AppStores,代码行数:40,代码来源:AppStoresServiceTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRedisClientsManager类代码示例发布时间:2022-05-24
下一篇:
C# IRecvPacket类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap