如何使用 .Net SDK check/get 在 Couchbase 中记录过期时间?

How to check/get document expiry in Couchbase using .Net SDK?

我需要使用 .Net SDK 在 Couchbase 中获取文档过期时间。 获取 API 不会 return 文件过期,它只是 returning 值。

遗憾的是,现在没有直接的方法来获取到期时间。但是,您可以使用视图来完成此任务:

创建一个发出到期时间的 view

function (doc, meta) {
      emit(doc.id, meta.expiration);
}

然后你可以query任何密钥的到期时间:

var query = bucket.CreateQuery("design-doc-name", "view-name”, false).Key("key-name");

 var result = bucket.Query<dynamic>(query);
 foreach (var row in result.Rows)
 {
    Console.WriteLine(row);
 }

请记住,offset expiry 被转换为 epoch timestamp cluster side。