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


C# ConnectionMultiplexer.GetDatabase方法代码示例

本文整理汇总了C#中StackExchange.Redis.ConnectionMultiplexer.GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionMultiplexer.GetDatabase方法的具体用法?C# ConnectionMultiplexer.GetDatabase怎么用?C# ConnectionMultiplexer.GetDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StackExchange.Redis.ConnectionMultiplexer的用法示例。


在下文中一共展示了ConnectionMultiplexer.GetDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Redis

        private Redis()
        {
            try
            {
                redis = ConnectionMultiplexer.Connect("localhost");
                DB = redis.GetDatabase();
            }
            catch (RedisConnectionException rce)
            {

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.Arguments = Environment.CurrentDirectory + @"\redis\redis.windows.conf";
                startInfo.FileName = Environment.CurrentDirectory + @"\redis\redis-server.exe";
                startInfo.WorkingDirectory = Environment.CurrentDirectory + @"\redis\";
                Process p = Process.Start(startInfo);
                Thread.Sleep(200);
                for (int i = 0; i < 3; ++i)
                {
                    try
                    {
                        redis = ConnectionMultiplexer.Connect("localhost");
                        DB = redis.GetDatabase();
                        break;
                    }
                    catch (RedisConnectionException rce2)
                    {
                        Thread.Sleep(1000);
                    }
                }
            }

        }
开发者ID:daishin-securities,项目名称:DSDistributedProcessingSystem,代码行数:32,代码来源:Redis.cs

示例2: RedisServer

        public RedisServer()
        {
            ConfigurationOptions config=new ConfigurationOptions();
            config.Password=ConfigurationSettings.AppSettings["RedisPass"];
            config.EndPoints.Add(ConfigurationSettings.AppSettings["RedisServer"]);

            redis = ConnectionMultiplexer.Connect(config);

            companies_db = redis.GetDatabase(0);
            relations_db = redis.GetDatabase(1);
        }
开发者ID:aydar-musin,项目名称:RedisUploader,代码行数:11,代码来源:Uploader.cs

示例3: RedisAdaptor

        public RedisAdaptor(List<EndPoint> endPoints)
        {
            var config = new ConfigurationOptions()
            {
                AllowAdmin = true,
            };

            foreach (var endPoint in endPoints)
            {
                config.EndPoints.Add(endPoint);
            }

            muxerInstance = ConnectionMultiplexer.Connect(config);

            Handle = muxerInstance.GetDatabase();

            var script = Load("update_multikeys_multifields.lua");

            //todo a hack way .. to be changed later
            foreach (var endPoint in muxerInstance.GetEndPoints())
            {
                var server = muxerInstance.GetServer(endPoint);

                updateScriptSha = server.ScriptLoad(script);
            }

            Handle.StringSet("test", "111");
        }
开发者ID:fingerpasswang,项目名称:Phial,代码行数:28,代码来源:RedisAdaptor.cs

示例4: OpenAsync

 public async Task OpenAsync(PartitionContext context)
 {
     if (!WebJobsHelper.RunAsWebJobs)
         Console.WriteLine(string.Format("EventProcessor initialization. Partition: '{0}', Offset: '{1}'",
             context.Lease.PartitionId, context.Lease.Offset));
     partitionContext = context;
     var retries = 3;
     while (retries > 0)
     {
         try
         {
             retries--;
             hubClient = EventHubClient.CreateFromConnectionString(
                 ConfigurationManager.ConnectionStrings["SigfoxDemoAlertSender"].ConnectionString,
                 "alert");
             cacheConnection = await ConnectionMultiplexer.ConnectAsync(ConfigurationManager.ConnectionStrings["SigfoxDemoCache"].ConnectionString);
             cacheDatabase = cacheConnection.GetDatabase();
             sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SigfoxDemoDatabase"].ConnectionString);
             //sqlConnection.Open();
             //sqlCommand = new SqlCommand("InsertAlert", sqlConnection) { CommandType = CommandType.StoredProcedure };
             //sqlCommand.Parameters.Add(new SqlParameter("@Device", SqlDbType.VarChar));
             retries = 0;
         }
         catch (Exception e)
         {
             Console.Error.WriteLine("Error opening destination Event Hub: " + e.Message);
             if (retries == 0)
                 throw;
         }
     }
     checkpointStopWatch = new Stopwatch();
     checkpointStopWatch.Start();
 }
开发者ID:danvy,项目名称:sigfox,代码行数:33,代码来源:EventProcessor.cs

示例5: WorkflowManagement

        internal WorkflowManagement(ConnectionMultiplexer mux, ITaskHandler taskHandler, WorkflowHandler workflowHandler, string identifier, IEnumerable<string> typesProcessed, ILua lua, EventHandler<Exception> exceptionHandler = null, Behaviours behaviours = Behaviours.All)
        {
            _taskHandler = taskHandler;

            _workflowHandler = workflowHandler;

            if (exceptionHandler != null)
            {
                ExceptionThrown += exceptionHandler;
            }

            _typesProcessed = typesProcessed;

            _db = mux.GetDatabase();

            _sub = mux.GetSubscriber();

            if (_typesProcessed == null || _typesProcessed.Count() == 0)
            {
                _sub.Subscribe("submittedTask", (c, v) =>
                {
                    ProcessNextTask();
                });
            }
            else
            {
                foreach(var t in _typesProcessed)
                {
                    _sub.Subscribe("submittedTask:" + t, (c, v) =>
                    {
                        ProcessNextTask(t);
                    });
                }
            }

            _sub.Subscribe("workflowFailed", (c, v) =>
            {
                ProcessNextFailedWorkflow();
            });

            _sub.Subscribe("workflowComplete", (c, v) =>
            {
                ProcessNextCompleteWorkflow();
            });

            _lua = lua;
            _lua.LoadScripts(_db, mux.GetServer("localhost:6379"));

            _identifier = identifier;

            if (behaviours.HasFlag(Behaviours.AutoRestart))
            {
                var resubmittedTasks = ResubmitTasks();

                foreach (var item in resubmittedTasks)
                {
                    Console.WriteLine("Resubmitted {0}", item);
                }
            }
        }
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:60,代码来源:WorkloadManagement.cs

示例6: ConnectAsync

 public async Task ConnectAsync()
 {
     if (_connection == null)
     {
         _connection = await ConnectionMultiplexer.ConnectAsync(_options.Configuration);
         _cache = _connection.GetDatabase();
     }
 }
开发者ID:RehanSaeed,项目名称:Caching,代码行数:8,代码来源:RedisCache.cs

示例7: Connect

 public void Connect()
 {
     if (_connection == null)
     {
         _connection = ConnectionMultiplexer.Connect(_options.Configuration);
         _cache = _connection.GetDatabase();
     }
 }
开发者ID:RehanSaeed,项目名称:Caching,代码行数:8,代码来源:RedisCache.cs

示例8: RedisCache

 /// <summary>
 /// Initializes a new instance of the <see cref="RedisCache"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="hostname">The hostname.</param>
 public RedisCache(string name, string hostname = "localhost")
     : base(name)
 {
     _redis = ConnectionMultiplexer.Connect(hostname);
     _redis.PreserveAsyncOrder = false;
     _redisDb = _redis.GetDatabase();
     _level1Cache = new MemoryCache(name);
 }
开发者ID:bradsjm,项目名称:DataflowPipe,代码行数:13,代码来源:RedisCache.cs

示例9: Init

 public async Task Init(Logger logger, IProviderConfiguration config, string providerName, int numQueues)
 {
     _logger = logger;
     _redisListBaseName = $"orleans-{providerName}-queue";
     ReadRedisConnectionParams(config);
     _connection = await ConnectionMultiplexer.ConnectAsync(_server);
     _database = _connection.GetDatabase(_databaseNum);
     logger.AutoInfo($"connection to Redis successful.");
     IsInitialised = true;
 }
开发者ID:amamh,项目名称:orleans-FastPipeStreamProvider,代码行数:10,代码来源:RedisQueueProvider.cs

示例10: DbClientRedis

        //-------------------------------------------------------------------------
        public DbClientRedis(string databaseName, string connectionString)
        {
            DatabaseNumber = int.Parse(databaseName);
            object asyncState = null;

            var c = ConfigurationOptions.Parse(connectionString);
            c.AllowAdmin = true;

            CM = ConnectionMultiplexer.Connect(c);
            DB = CM.GetDatabase(DatabaseNumber, asyncState);
        }
开发者ID:CragonGame,项目名称:GameCloud.IM,代码行数:12,代码来源:DbClientRedis.cs

示例11: RedisClient

        private RedisClient(IPEndPoint endPoint, ConnectionMultiplexer redis)
            : base(endPoint)
        {
            if (null == redis)
            {
                throw new ArgumentNullException("redis");
            }

            this.redis = redis;
            this.db = redis.GetDatabase();
        }
开发者ID:jango2015,项目名称:Ironclad,代码行数:11,代码来源:RedisClient.cs

示例12: Execute

        internal static void Execute(ConnectionMultiplexer redis)
        {
            Redis = redis;
            var db = Redis.GetDatabase();

            Console.Clear();

            SimpleTest();

            Console.Write("<ENTER> to close ");
            Console.ReadLine();
        }
开发者ID:Jens-G,项目名称:Redis-Samples,代码行数:12,代码来源:TestSortedSimple.cs

示例13: RedisConnectionManager

        public RedisConnectionManager(IConfig config)
        {
            ConfigurationOptions options = new ConfigurationOptions();
            options.EndPoints.Add(config.GetString("redisCacheHostName"), config.GetInt("redisCachePortNumber"));
            options.Ssl = config.GetBool("redisCacheUseSSL");
            options.Password = config.GetString("redisCachePassword");
            options.AbortOnConnectFail = false;
            options.ConnectTimeout = 30000;

            connection = ConnectionMultiplexer.Connect(options);
            cache = connection.GetDatabase();
        }
开发者ID:mbgreen,项目名称:GHV,代码行数:12,代码来源:RedisConnectionManager.cs

示例14: Redis

 private void Redis(string message)
 {
     if (_connection == null)
     {
         _connection = ConnectionMultiplexer.Connect(ConfigurationManager.ConnectionStrings["AzureRedis"].ToString());
         if (_cache == null)
         {
             _cache = _connection.GetDatabase();
         }
     }
         _cache.ListLeftPush("s", message);
     
 }
开发者ID:tzkwizard,项目名称:ELS,代码行数:13,代码来源:QueueAndredis.cs

示例15: Run

        internal static void Run(StackExchange.Redis.ConnectionMultiplexer redis)
        {
            Console.WriteLine("Hit <ESC> to shutdown this worker.");

            Redis = redis;
            while ((!Console.KeyAvailable) || (Console.ReadKey().Key != ConsoleKey.Escape))
            {
                var msg = Redis.GetDatabase().ListLeftPop(Tools.WORKQUEUE);
                if (!msg.IsNullOrEmpty)
                    HandleClusterWork(msg);
                else
                    Thread.Sleep(0);
            }
        }
开发者ID:Jens-G,项目名称:Redis-Samples,代码行数:14,代码来源:Worker.cs


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