gpt4 book ai didi

azure - StackExchange Redis 客户端 StringSet 返回 false?

转载 作者:IT王子 更新时间:2023-10-29 06:02:49 27 4
gpt4 key购买 nike

我们已经使用 StackExchange Redis .Net 客户端几个月了,没有出现任何问题。我们的日志表明 StringSet 最近在一个小时内返回 false 数千次,但它再次按预期工作。

我在任何地方都找不到 FALSE 的含义。我认为这意味着该值没有放入缓存中,但如果这是正确的,我如何知道为什么?客户端没有抛出异常。有人可以向我展示描述返回值以及如何排除故障的 API 规范吗?

如果重要的话,我们正在 Azure 中运行 Redis。

result = cache.StringSet(fullKey, value, GetCacheTime(cacheType));
if (!result)
{
if (_logger != null)
{
_logger.LogError( "Failed to Set Cache");
}
}

最佳答案

http://redis.io/commands/set

Simple string reply: OK if SET was executed correctly. Null reply: a Null Bulk Reply is returned if the SET operation was not performed becase the user specified the NX or XX option but the condition was not met.

虽然看起来您正在使用 SETEX ( http://redis.io/commands/setex ),但您是否将有效的时间跨度设置为第三个参数?

SETEX is atomic, and can be reproduced by using the previous two commands inside an MULTI / EXEC block. It is provided as a faster alternative to the given sequence of operations, because this operation is very common when Redis is used as a cache. An error is returned when seconds is invalid.

关于azure - StackExchange Redis 客户端 StringSet 返回 false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26951830/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com