【发布时间】:2019-10-18 22:16:33
【问题描述】:
我正在使用带有 StackExchange.Redis 1.2.6 的 Azure Function V1。每分钟接收 1000 条消息的功能,对于每条消息,对于每台设备,我正在检查 Redis。我注意到当我们当时有更多消息时,我们会遇到错误。
执行函数时出现异常:TSFEventRoutingFunction 没有可用于服务此操作的连接:HGET GEO_DYNAMIC_hash;无法连接到 redis 服务器;连接超时; IOCP: (Busy=1,Free=999,Min=24,Max=1000), WORKER: (Busy=47,Free=32720,Min=24,Max=32767), Local-CPU: n/a 不是可以连接到 redis 服务器;连接超时
CacheService 由 MS 推荐
public class CacheService : ICacheService
{
private readonly IDatabase cache;
private static readonly string connectionString = ConfigurationManager.AppSettings["RedisConnection"];
public CacheService()
{
this.cache = Connection.GetDatabase();
}
private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
return ConnectionMultiplexer.Connect(connectionString);
});
public static ConnectionMultiplexer Connection
{
get
{
return lazyConnection.Value;
}
}
public async Task<string> GetAsync(string hashKey, string ruleKey)
{
return await this.cache.HashGetAsync(hashKey, ruleKey);
}
}
我在 Azure 函数中注入 ICacheService 并在每个请求上调用 GetAsync 方法。
使用 Azure Redis 实例 C3
目前,您可以看到我只有一个连接,创建多个连接将有助于解决这个问题吗?或任何其他解决/理解此问题的建议。
【问题讨论】:
标签: c# redis stackexchange.redis azure-redis-cache