[英]How to set the Redis Server pool size with the CacheManager?
[C#]如何使用CacheManager设置Redis服务器池大小?
我并发错误并发:没有连接可用于服务此操作:HMGET,如何设置连接池大小?
No connection is available to service this operation: HMGET U
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
at StackExchange.Redis.RedisDatabase.HashGet(RedisKey key, RedisValue[] hashFields, CommandFlags flags)
at CacheManager.Redis.RedisCacheHandle`1.<>c__DisplayClass25_0.<GetCacheItemInternal>b__0()
at CacheManager.Redis.RetryHelper.Retry[T](Func`1 retryme, Int32 timeOut, Int32 retries)
at CacheManager.Redis.RedisCacheHandle`1.Retry[T](Func`1 retryme)
at CacheManager.Redis.RedisCacheHandle`1.GetCacheItemInternal(String key, String region)
at CacheManager.Redis.RedisCacheHandle`1.GetCacheItemInternal(String key)
at CacheManager.Core.Internal.BaseCache`1.GetCacheItem(String key)
at CacheManager.Core.BaseCacheManager`1.GetCacheItemInternal(String key, String region)
at CacheManager.Core.BaseCacheManager`1.GetCacheItemInternal(String key)
at CacheManager.Core.Internal.BaseCache`1.GetCacheItem(String key)
at CacheManager.Core.Internal.BaseCache`1.Get(String key)
at CacheManager.Core.Internal.BaseCache`1.Get[TOut](String key)
=======================
var cache = CacheFactory.Build("RuntimeCache", settings =>
{
settings.WithSystemRuntimeCacheHandle("RuntimeCache")
.WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(10))
.And
.WithRedisConfiguration("RedisCache", config =>
{
config.WithAllowAdmin()
.WithDatabase(1)
.WithPassword(password)
.WithEndpoint(host, port);
})
.WithMaxRetries(100)
.WithRetryTimeout(50)
.WithRedisBackPlate("RedisCache")
.WithRedisCacheHandle("RedisCache", true)
.WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(30));
});
Stackexchange.Redis不使用连接池,而是使用multiplexing 。
您可以通过配置 => syncTimeout更改库等待同步调用的时间(默认为1000ms)。 (要与CacheManager一起使用,请使用基于连接字符串的配置或自己创建Multiplexer
)。 这可能会改善您的体验。
无论如何,超时和此类连接错误在大多数情况下与客户端无关,并且是由Redis服务器的单线程性质引起的,尤其是如果您达到服务器上的内存限制并且Redis尝试删除密钥,或者Redis尝试执行以下操作:备份到磁盘...
我无法给您一个更明确的答案,因为这些问题很大程度上取决于您要执行的操作以及您所使用的Redis服务器...
您将找到有关该错误的其他许多问与答 ,例如,请参见StackExchange.Redis超时和“无连接可用于服务此操作”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.