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


C# IRedisClient类代码示例

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


IRedisClient类属于命名空间,在下文中一共展示了IRedisClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DAO

 public DAO()
 {
     _client = new RedisClient();
     //Set to 1 to avoid conflicts with any default installs
     //TODO: make configurable
     _client.Db = 1;
 }
开发者ID:HofmaDresu,项目名称:LunchTrainPlanner,代码行数:7,代码来源:DAO.cs

示例15: RedisRegistryProvider

        public RedisRegistryProvider()
        {
            if (SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration == null)
                throw new Exception("注册中心配置有误");

            string url = SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration.Url;
            string collectionName = "RegistryData";

            var attrs = DictionaryUtils.GetFromConfig(SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration.AddtionalFields);
            if (attrs != null && attrs.ContainsKey(AttrKeys.Registry_RedisCollectionName) )
            {
                if (!string.IsNullOrEmpty(attrs[AttrKeys.Registry_RedisCollectionName]))
                {
                    collectionName = attrs[AttrKeys.Registry_RedisCollectionName];
                }
            }

            _redisClient = new RedisClient(url);
            _typedClient = _redisClient.As<RegistryDataInfo>();
            _table = _typedClient.Lists[collectionName];

            _redisSubscription = _redisClient.CreateSubscription();
            _redisSubscription.OnMessage += (channel, msg) =>
            {
                var data = _serializer.Deserialize<ServiceRegistryMetta>(msg);
                if (this.ServiceChanged == null) return;

                this.ServiceChanged(this, new ServiceNotifyEventArgs
                {
                    Data = data
                });
            };
        }
开发者ID:tukzer,项目名称:Seif,代码行数:33,代码来源:RedisRegistry.cs


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