Can you retrieve the TTL in Redis c#?

拜拜、爱过 提交于 2020-06-25 21:03:50

问题


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


回答1:


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!



来源:https://stackoverflow.com/questions/28797253/can-you-retrieve-the-ttl-in-redis-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!