upsert() 是否在 couchbase 中保留 TTL?

Does upsert() preserve TTL in couchbase?

这个很容易通过代码弄清楚,但由于它违反直觉(并且没有记录)我在这里记录它:

Upsert(insert/update 操作)是否在 couchbase 中保留 TTL?

换句话说,如果我运行这个代码:

cb.upsert('hello',{'hi':'there'},ttl=10)
cb.upsert('hello',{'hi':'there'})

创建(然后更新)的文档会在 10 秒后过期吗?

所以,没有。第二个 upsert 重置 TTL - 文档将永不过期。

请注意,此行为在 couchbase 中并不一致:incr() 操作(对于计数器)不会重置 TTL。