Search code examples
c#azurestackexchange.redisttl

StackExchange.Redis | TTL -2 | Issue


What does TTL Status Code -2 mean? I am trying to set expiration for my Redis Key while calling StringSet(key, value, expirationTimeSpan).

I have set expiry by 1 minute. When I run TTL MyKey, it counts down 59, 58, 57,.. suddenly it drops to -2.

I am using Azure Redis Cache Service Basic 256mb and 2.5gb scale.

What was the problem? Is it something to do with active\ passive expiry?


Solution

  • From the docs:

    Starting with Redis 2.8 the return value in case of error changed:

    • The command returns -2 if the key does not exist.
    • The command returns -1 if the key exists but has no associated expire.

    So: it got deleted, presumably.