你能在 Redis c# 中检索 TTL 吗?

Can you retrieve the TTL in Redis c#?

有什么方法可以在 c# 中获取 StackExchange.Redis 密钥的 TTL(生存时间)?

我对redis没有多少经验,但我相信你指的是:(http://redis.io/commands/ttl).

如果是这样,请在您的数据库连接对象上尝试 运行.KeyTimeToLive("RedisKeyHere")。

参见示例:

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

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

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

    }
}

希望这些信息对您有所帮助!