Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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#?

like image 641
Suamere Avatar asked Mar 01 '15 18:03

Suamere


1 Answers

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!

like image 195
Venkata.Mutyala Avatar answered Nov 01 '22 10:11

Venkata.Mutyala