相关疑难解决方法(0)

使用Azure Redis的StackExchange.Redis速度非常慢或引发超时错误

我将所有现有的Azure In-Role缓存使用移至Redis,并决定将Azure Redis预览与StackExchange.Redis库(https://github.com/StackExchange/StackExchange.Redis)一起使用.我为它编写了所有代码没有太多问题,但是在运行时它绝对非常慢并且不断抛出超时错误(我的超时时间设置为15秒).

以下是我如何设置Redis连接并将其用于简单操作的相关代码:

    private static ConnectionMultiplexer _cacheService;
    private static IDatabase _database;
    private static object _lock = new object();

    private void Initialize()
    {
        if (_cacheService == null)
        {
            lock (_lock)
            {
                if (_cacheService == null)
                {
                    var options = new ConfigurationOptions();
                    options.EndPoints.Add("{my url}", 6380);
                    options.Ssl = true;
                    options.Password = "my password";
                    // needed for FLUSHDB command
                    options.AllowAdmin = true;

                    // necessary?
                    options.KeepAlive = 30;
                    options.ConnectTimeout = 15000;
                    options.SyncTimeout = 15000;

                    int database = 0;

                    _cacheService = ConnectionMultiplexer.Connect(options);
                    _database …
Run Code Online (Sandbox Code Playgroud)

c# asp.net caching azure redis

29
推荐指数
3
解决办法
3万
查看次数

标签 统计

asp.net ×1

azure ×1

c# ×1

caching ×1

redis ×1