Description
IDocument<T> has an Expiry property, as documented on this page
How to reproduce:
- Run the program below
- Observe that the document is created in Couchbase UI
- Wait some time
- Observe that the document never disappears
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Couchbase;
|
|
|
namespace BrianCouchbase1
|
{
|
class Program
|
{
|
|
private static readonly Cluster Cluster = new Couchbase.Cluster();
|
|
static void Main(string[] args)
|
{
|
|
using (var bucket = Cluster.OpenBucket())
|
{
|
|
var document = new Document<dynamic>
|
{
|
Id = "Hello3",
|
Expiry = 10000,
|
Content = new
|
{
|
name = "I expire in 10000 milliseconds. It is now 3:52pm."
|
}
|
};
|
|
var upsert = bucket.Upsert(document);
|
if (upsert.Success)
|
{
|
var get = bucket.GetDocument<dynamic>(document.Id);
|
document = get.Document;
|
var msg = string.Format("{0} {1}!", document.Id, document.Content.name);
|
Console.WriteLine(msg);
|
}
|
Console.Read();
|
}
|
|
}
|
}
|
}
|