问题标签 [stackexchange.redis]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
2976 浏览

c# - 在 StackExchange.Redis 上配置连接池

我开始使用 StackExchange.Redis 作为我的 c# redis 客户端。

我尝试做的第一件事是在 StackExchange 上设置连接池,经过一些互联网搜索并检查了我找不到的代码。

是否可以在此客户端上设置打开连接的数量或至少控制它?

0 投票
1 回答
15416 浏览

optimization - Pipelining vs Batching in Stackexchange.Redis

I am trying to insert a large(-ish) number of elements in the shortest time possible and I tried these two alternatives:

1) Pipelining:

2) Batching:

I am not noticing any significant time difference (actually I expected the batch method to be faster): for approx 250K inserts I get approx 7 sec for pipelining vs approx 8 sec for batching.

Reading from the documentation on pipelining,

"Using pipelining allows us to get both requests onto the network immediately, eliminating most of the latency. Additionally, it also helps reduce packet fragmentation: 20 requests sent individually (waiting for each response) will require at least 20 packets, but 20 requests sent in a pipeline could fit into much fewer packets (perhaps even just one)."

To me, this sounds a lot like the a batching behaviour. I wonder if behind the scenes there's any big difference between the two because at a simple check with procmon I see almost the same number of TCP Sends on both versions.

0 投票
1 回答
7407 浏览

c# - StackExchange.Redis 可以用来存储 POCO 吗?

我正在尝试使用两个著名的 C# 驱动程序ServiceStackStackExchange来评估 Redis 。不幸的是,我不能使用 ServiceStack,因为它不是免费的。现在我正在尝试 StackExchange。

有人知道我是否可以使用 StackExchange.Redis 坚持 POCO?

0 投票
1 回答
7646 浏览

c# - StackExchange.Redis 异步调用比同步调用慢

我知道异步方法的重点不是提高性能,但我发现 StackExchange.Redis 上的异步方法同步方法花费的时间要长得多。

异步调用大约需要 5000 毫秒,而非异步调用平均需要大约 30 毫秒。我的 redis 托管在 azure 上。有什么想法吗?

编辑:我在这里谈论一个请求。SortedSetRangeByScore api 调用在 30 毫秒内返回,而 SortedSetRangeByScoreAsync api 调用在 5000 毫秒内返回。

0 投票
1 回答
514 浏览

azure - 从客户端获取 redis azure 缓存的 maxmemory

我们正在使用 Azure Redis 缓存,我们需要监控它的状态。我们需要的一件事是有关最大内存的信息。目前,我们手动输入信息,但我们希望将来避免它。用于此目的的标准命令config get maxmemory在 Azure 中被禁用。为了完整起见,我们使用 StackExchange.Redis 作为客户端。

任何想法,如何获取信息?另外,为什么禁用命令的获取版本?

0 投票
1 回答
651 浏览

.net - “StackExchange.Redis.ITransaction”不包含“StringSetAsync”的定义

我在 Redis 上使用事务并使用 StackExchange.Redis 提供程序。

我有大量用于事务的 StringSetAsync 操作。

我在使用 StringSetAsync 时遇到了错误:

RuntimeBinderException 被捕获

“StackExchange.Redis.ITransaction”不包含“StringSetAsync”的定义

堆栈跟踪:

在 CallSite.Target(Closure, CallSite, ITransaction, String, Object) 在 Repository.RedisDatabaseContextBase.SetRecord(IBasicRedisEntity redisEntity, Boolean isNewRecord)

====

添加:

这是反映问题的代码示例。Marc 是对的,一切都与动态有关。

0 投票
2 回答
2984 浏览

redis - Stackexchange.Redis 为什么 ConnectionMultiplexer.Connect 建立两个客户端连接?

我很好奇为什么ConnectionMultiplexer.Connect(options)尝试将 2 个客户端连接到 RedisDB 而不是 1 个?每次连接时,我都会看到另外 2 个客户端连接到我的 RedisDB。

0 投票
2 回答
3975 浏览

c# - Pub/Sub Redis,能否监控已发布的消息是否被消费?

我有一个通过不同主题发布消息的 redis 实例。与其实现复杂的心跳机制(很复杂,因为如果消息没有被消费,实例会在一段时间后停止发布消息),有没有办法检查 pubs 是否被任何人消费?

例如,实例向和RedisServer发布消息。订阅和订阅。当出于某种原因停止使用消息时,我想知道它并决定何时停止将消息发布到. 消费的终止是不可预测的,因此我无法告知终止/取消订阅。topic1topic2RedisClient1topic1RedisClient2topic2RedisClient2topic2RedisServertopic2topic2RedisServer

我想如果有办法让 redis 实例知道某个主题的消息是否被消费,那么这将是非常有用的信息。

知道这是否可能吗?

0 投票
1 回答
481 浏览

c# - 获取常规 ConfigurationErrorsException

我正在为我的 MVC 应用程序使用 Stackexchange redis,并且我得到了如下的常规 w3wp 异常。它不会发生在生产中,所以我想知道这是否与 Visual Studio 有关?

使用:Visual Studio Premium 2013 版本:12.0.31101.00 更新 4

我正在使用 Microsoft 提供的ASP.NET 会话状态提供程序,在我的 web.config 中它是这样的:(我指的是 azure redis)

当我打开应用程序时,每隔几分钟我就会收到此异常。

0 投票
1 回答
682 浏览

unit-testing - 如何使用 Moq 模拟 StackExchange.Redis 库抛出的异常?

我正在做一个项目,我想使用 StackExchange.Redis 库连接到 Redis 数据库。此外,我想在我们的单元测试中使用 Moq 作为模拟库,但我遇到了一个障碍,我需要一些帮助来解决。

我的具体问题是,我有一个命令/响应架构,并且我正在尝试测试一个缓存“包装器”,该缓存“包装器”在执行实际工作以返回响应之前检查缓存是否可以满足命令。一个重要的考虑因素是缓存故障不应该停止处理请求,因此我想模拟 StackExchange.Redis IDatabase接口的某些故障。但是,我似乎无法弄清楚如何从我的模拟对象中抛出 RedisException。例如,我想只使用下面的代码,但它不能编译,因为这个库抛出的异常没有公共构造函数。

有没有更好的方法来模拟 StackExchange.Redis 库中的故障?我觉得我在 Moq 或如何针对这个库进行测试时遗漏了一些明显的东西。