【问题标题】:Key not available in Redis cacheRedis 缓存中的键不可用
【发布时间】:2018-04-16 20:17:37
【问题描述】:

如果传递给 StackExchange.Redis KeyDelete 方法的键在 redis 缓存中不可用,会发生什么情况。它是抛出任何异常还是在内部处理丢失的键而不抛出任何异常?

long KeyDelete(RedisKey[] keys, CommandFlags flags = CommandFlags.None);

【问题讨论】:

    标签: azure stackexchange.redis


    【解决方案1】:

    如果您在 KeyDelete 上按 F12 以查看定义,它会告诉您 “如果键不存在,则忽略它”

    // Summary:
    //     Removes the specified keys. A key is ignored if it does not exist.
    //
    // Returns:
    //     The number of keys that were removed.
    //
    // Remarks:
    //     http://redis.io/commands/del
    long KeyDelete(RedisKey[] keys, CommandFlags flags = CommandFlags.None);
    

    【讨论】:

    • 另外:请查看https://redis.io/commands/del 链接。它展示了一个简单但很好的例子。该命令返回被删除的键的数量,所以如果你的不存在,它将返回 0。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-28
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 2015-11-27
    • 2013-01-28
    • 2015-05-29
    相关资源
    最近更新 更多