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

C# BookSleeve.RedisConnection类代码示例

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

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



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

示例1: GetRedisConnection

        private static async Task<RedisConnection> GetRedisConnection(string host)
        {
            RedisConnection c = new RedisConnection(host);
            await c.Open();
            return c;

        }
开发者ID:ryantomlinson,项目名称:EventStreamR,代码行数:7,代码来源:RedisBooksleevePersistence.cs


示例2: RedisBooksleevePersistence

 public RedisBooksleevePersistence()
 {
     if (conn == null)
     {
         conn = GetRedisConnection("localhost").Result;
     }
 }
开发者ID:ryantomlinson,项目名称:EventStreamR,代码行数:7,代码来源:RedisBooksleevePersistence.cs


示例3: Setup

 public void Setup()
 {
     var connection = new RedisConnection("127.0.0.1", allowAdmin: true);
     connection.Open();
     connection.Server.FlushDb(0);
     connection.Close(false);
 }
开发者ID:kumaie,项目名称:AspNetRedisProviders,代码行数:7,代码来源:RoleProviderTests.cs


示例4: PerformBitOperation

        internal async Task<long> PerformBitOperation(
            RedisConnection connection)
        {
            var keys = new[] { LeftKey, RightKey };

            if ("AND".Equals(Operation, StringComparison.Ordinal))
            {
                return await connection.Strings.BitwiseAnd(Db, Key, keys);
            }
            
            if ("OR".Equals(Operation, StringComparison.Ordinal))
            {
                return await connection.Strings.BitwiseOr(Db, Key, keys);
            }

            if ("XOR".Equals(Operation, StringComparison.Ordinal))
            {
                return await connection.Strings.BitwiseXOr(Db, Key, keys);
            }

            throw new InvalidOperationException(
                string.Format(
                    CultureInfo.CurrentUICulture,
                    ErrorMessages.CompositeUserActivityReport_PerformBitOperation_Unsupported,
                    Operation));
        }
开发者ID:jesusgarza,项目名称:MinutemanDotNet,代码行数:26,代码来源:CompositeUserActivityReport.cs


示例5: foo

 public static void foo()
 {
     using (var redis = new RedisConnection("goosefish.redistogo.com", 9836, -1, "88f5c87381f5564b18b4ecba2647e9ab")) {
         redis.Open();
         redis.Lists.AddLast(1, "w00t", "t00t");
     }
 }
开发者ID:timothypratley,项目名称:locstream,代码行数:7,代码来源:EventRecorder.cs


示例6: RedisSignalBus

 public RedisSignalBus(RedisConnection redisConnection)
 {
     _handlers = new ConcurrentDictionary<string, SafeSet<EventHandler<SignaledEventArgs>>>();
     _redisConnection = redisConnection;
     _subscriberConnection = _redisConnection.GetOpenSubscriberChannel();
     _subscriberConnection.MessageReceived += OnRedisMessageReceived;
 }
开发者ID:JasonPunyon,项目名称:SignalR,代码行数:7,代码来源:RedisSignalBus.cs


示例7: ConnectionReady

        private bool ConnectionReady()
        {
            if (_redisConnection == null || _redisConnection.State != RedisConnectionBase.ConnectionState.Open)
            {
                lock (_connectionLock)
                {
                    if (_redisConnection == null || _redisConnection.State != RedisConnectionBase.ConnectionState.Open)
                    {
                        _redisConnection = new RedisConnection(Host, Port, password: Password, maxUnsent: 1);

                        try
                        {
                            _redisConnection.Open().Wait();
                            return true;                
                        } 
                        catch (Exception ex)
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
开发者ID:Rustemt,项目名称:SignalR.Redis,代码行数:25,代码来源:RedisMessageStore.cs


示例8: GetBrushActions

 public List<CanvasBrushAction> GetBrushActions(string canvasId, int currentPosition)
 {
     List<CanvasBrushAction> actions = new List<CanvasBrushAction>();
     string[] storedActions = null;
     using (var conn = new RedisConnection(_redisConfiguration.HostName, _redisConfiguration.
     Port, password: _redisConfiguration.Password))
     {
         conn.Open();
         var rangeTask = conn.Lists.RangeString(0, ACTION_PREFIX + canvasId, currentPosition,
         Int32.MaxValue);
         storedActions = rangeTask.Result;
     }
     if (storedActions != null)
     {
         foreach (string storedAction in storedActions)
         {
             actions.Add(JsonConvert.DeserializeObject<CanvasBrushAction>(storedAction));
         }
         actions.Sort(new Comparison<CanvasBrushAction>((a, b) =>
         {
             return a.Sequence.
                 CompareTo(b.Sequence);
         }));
     }
     return actions;
 }
开发者ID:asifashraf,项目名称:proSignalR,代码行数:26,代码来源:RedisStorage.cs


示例9: CanNotOpenNonsenseConnection

 public void CanNotOpenNonsenseConnection()
 {
     using (var conn = new RedisConnection("127.0.0.1", 6500))
     {
         conn.Wait(conn.Open());
     }
 }
开发者ID:rhagigi,项目名称:Booksleeve,代码行数:7,代码来源:Config.cs


示例10: CanNotOpenNonsenseConnection_IP

 public void CanNotOpenNonsenseConnection_IP()
 {
     using (var conn = new RedisConnection(Config.LocalHost, 6500))
     {
         conn.Wait(conn.Open());
     }
 }
开发者ID:raycode,项目名称:booksleeve,代码行数:7,代码来源:Config.cs


示例11: GetOpen

        public RedisConnection GetOpen()
        {
            lock (syncConnection)
            {
                if (_Connection != null && !(_Connection.State == RedisConnectionBase.ConnectionState.Closed || _Connection.State == RedisConnectionBase.ConnectionState.Closing))
                {
                    return _Connection;
                }

                if (_Connection == null || (_Connection.State == RedisConnectionBase.ConnectionState.Closed || _Connection.State == RedisConnectionBase.ConnectionState.Closing))
                {
                    try
                    {
                        RoqueTrace.Source.Trace(TraceEventType.Information, "[REDIS] connecting to {0}:{1}", _Host, _Port);

                        _Connection = new RedisConnection(_Host, _Port, _Timeout);
                        var openAsync = _Connection.Open();
                        _Connection.Wait(openAsync);

                        RoqueTrace.Source.Trace(TraceEventType.Information, "[REDIS] connected");
                    }
                    catch (Exception ex)
                    {
                        RoqueTrace.Source.Trace(TraceEventType.Error, "[REDIS] error connecting to {0}:{1}, {2}", _Host, _Port, ex.Message, ex);
                        throw;
                    }
                }
                return _Connection;
            }
        }
开发者ID:BlogTalkRadio,项目名称:Roque,代码行数:30,代码来源:RedisLiveConnection.cs


示例12: Test

        public void Test()
        {
            Debug.WriteLine("Iniciando");

            using (var conn = new RedisConnection("localhost"))
            {
                conn.Open();
                conn.Strings.Set(0, "nome", "joão");
            }

            Thread.Sleep(2000);

            using (var conn = new RedisConnection("localhost", 6380))
            {
                conn.Open();
                conn.Strings.GetString(0, "nome").Result.ShouldEqual("joão");
            }

            this.redisMaster.Kill();

            Thread.Sleep(2000);

            using (var conn = new RedisConnection("localhost", 6380))
            {
                conn.Open();
                conn.Strings.GetString(0, "nome").Result.ShouldEqual("joão");

                conn.Strings.Set(0, "idade", "27");
                conn.Strings.GetString(0, "idade").Result.ShouldEqual("27");
            }

            Debug.WriteLine("Fim");
        }
开发者ID:joaofx,项目名称:redisreplication,代码行数:33,代码来源:RedisTest.cs


示例13: should_result_in_field5_with_6

        public void should_result_in_field5_with_6()
        {
            using (var client = new RedisConnection("localhost"))
            {
                client.Open();

                var redis = new RedisBooksleeveConnector(client);

                var key = "hello";
                var field1 = "world";
                var field2 = "world2";
                var field3 = "w3";
                var field4 = "w4";
                var field5 = "w5";
                var field6 = "w6";

                redis.HSet(key, field1, "1");
                redis.HSet(key, field2, "2");
                redis.HSet(key, field3, "3");
                redis.HSet(key, field4, "4");
                redis.HSet(key, field5, "5");
                redis.HSet(key, field6, "6");

                var result = redis.HGetAll(key);
                Assert.That(result[field5], Is.EqualTo("5"));
            }
        }
开发者ID:scobrown,项目名称:Resque.RedisClient.Booksleeve,代码行数:27,代码来源:RedisClient.cs


示例14: CanNotOpenNonsenseConnection_DNS

 public void CanNotOpenNonsenseConnection_DNS()
 {
     using (var conn = new RedisConnection("doesnot.exist.ds.aasd981230d.com", 6500))
     {
         conn.Wait(conn.Open());
     }
 }
开发者ID:raycode,项目名称:booksleeve,代码行数:7,代码来源:Config.cs


示例15: CreateRedisConnection

        public Task<RedisConnection> CreateRedisConnection()
        {
            var settings = RedisConnectionProvider.Instance.ConnectionsSettings;
            var redisConnection = new RedisConnection(host: settings["host"], port: Convert.ToInt32(settings["port"]), password: settings["password"]);
            var taskCreateConnection = new TaskCompletionSource<RedisConnection>();

            try
            {
                redisConnection.Open().ContinueWith((task) =>
                    {
                        if (!task.IsFaulted)
                        {
                            taskCreateConnection.SetResult(redisConnection);
                        }
                        else
                        {
                            task.Exception.Handle(x => true);
                            taskCreateConnection.SetException(task.Exception);
                        }
                    }, TaskScheduler.Default);
            }
            catch (Exception ex)
            {
                taskCreateConnection.SetException(ex);
            }

            return taskCreateConnection.Task;
        }
开发者ID:g-un--,项目名称:log4net.redis,代码行数:28,代码来源:RedisConnectionFactory.cs


示例16: AsyncRedisUsage

        // could also be void; only a Task here so I can Wait on
        // completion from my Main method, which is not declared
        // as async
        async static Task AsyncRedisUsage()
        {
            const int db = 4; // no reason

            using(var conn = new RedisConnection("127.0.0.1"))
            {
                // let's wait until all handshakes have happened
                await conn.Open();
                var existed = conn.Keys.Remove(db, "some-key");
                for (int i = 0; i < 100; i++)
                {   // this are also tasks, but I don't
                    // need to wait on them in this case
#pragma warning disable 4014
                    conn.Strings.Increment(db, "some-key");
#pragma warning restore 4014
                }
                // at this point, some messages are flying around
                // from a background queue, with responses being
                // handled by IOCP; let's add a GET onto the
                // bottom of the queue, and let other stuff
                // happen until we have the answer (obviously
                // we could make much more subtle use here, by
                // awaiting multiple things requested much earlier,
                // or by doing some SQL Server work etc before
                // calling await, essentially acting as a "join")
                string result = await conn.Strings.GetString(db, "some-key");
                Console.WriteLine(await existed
                    ? "(it already existed; we removed it)"
                    : "(it didn't exist)");
                Console.WriteLine(result);
            }
        }
开发者ID:raycode,项目名称:booksleeve,代码行数:35,代码来源:Program.cs


示例17: RedisMessageBus

        public RedisMessageBus(string server, int port, string password, int db, IEnumerable<string> keys, IDependencyResolver resolver)
            : base(resolver)
        {
            _db = db;
            _keys = keys.ToArray();

            _connection = new RedisConnection(host: server, port: port, password: password);

            _connection.Closed += OnConnectionClosed;
            _connection.Error += OnConnectionError;

            // Start the connection
            _connectTask = _connection.Open().Then(() =>
            {
                // Create a subscription channel in redis
                _channel = _connection.GetOpenSubscriberChannel();

                // Subscribe to the registered connections
                _channel.Subscribe(_keys, OnMessage);

                // Dirty hack but it seems like subscribe returns before the actual
                // subscription is properly setup in some cases
                while (_channel.SubscriptionCount == 0)
                {
                    Thread.Sleep(500);
                }
            });
        }
开发者ID:neiz,项目名称:SignalR,代码行数:28,代码来源:RedisMessageBus.cs


示例18: ConnectionReady

 public bool ConnectionReady()
 {
     if (_redisConnection == null || _redisConnection.State != RedisConnectionBase.ConnectionState.Open)
     {
         lock (_connectionLock)
         {
             if (_redisConnection == null || _redisConnection.State != RedisConnectionBase.ConnectionState.Open)
             {
                 _redisConnection = new RedisConnection(Host, Port, password: Password);
                 try
                 {
                     _redisConnection.Open();
                     _subscriberConnection = _redisConnection.GetOpenSubscriberChannel();
                     _subscriberConnection.MessageReceived += OnRedisMessageReceived;
                     _subscriberConnection.Error += OnRedisError;
                     return true;
                 } 
                 catch (Exception ex)
                 {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:Rustemt,项目名称:SignalR.Redis,代码行数:26,代码来源:RedisSignalBus.cs


示例19: ClearData

 public void ClearData()
 {
     connection = new RedisConnection("localhost", 6379, -1, null, 2147483647, true,10000);
     subject = new RedisRepository(connection);
     connection.Open();
     connection.Server.FlushDb(db);
 }
开发者ID:Alexssandrolima,项目名称:CRUD,代码行数:7,代码来源:Redis_persistence.cs


示例20: Build

 /// <summary>
 /// Builds the repository from scratch to ensure a cold start
 /// </summary>
 public void Build()
 {
     this.connection = new RedisConnection(this.connectionString.Split(':')[0], Convert.ToInt32(this.connectionString.Split(':')[1]), allowAdmin: true);
     Serializer.PrepareSerializer<University>();
     this.connection.Open();
     Task task = this.connection.Server.FlushDb(0);
     task.Wait();
 }
开发者ID:DNUG,项目名称:DNUG-October-Event,代码行数:11,代码来源:RedisRepository.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Data.SqlFilter类代码示例发布时间:2022-05-24
下一篇:
C# TypeSystem.InternalMethod类代码示例发布时间: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