Suamere
Suamere

Reputation: 6258

Can you retrieve the TTL in Redis c#?

Is there any way to get the TTL (Time to Live) of a StackExchange.Redis key in c#?

Upvotes: 9

Views: 6350

Answers (1)

Venkata.Mutyala
Venkata.Mutyala

Reputation: 705

I have little experience with redis but I believe you are referring to: (http://redis.io/commands/ttl).

If so, try running the .KeyTimeToLive("RedisKeyHere") on your database connection object.

See example:

class Program
{
    static void Main(string[] args)
    {

        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");

        var db = redis.GetDatabase(0);
        var timeToLive = db.KeyTimeToLive("RedisKeyNameHere");

    }
}

I hope this information helps!

Upvotes: 26

Related Questions