Details
-
Bug
-
Resolution: Fixed
-
None
-
*Location*: https://docs.couchbase.com/server/6.0/eventing/eventing-examples-docexpiry.html
*Referrer*: https://docs.couchbase.com/server/6.0/eventing/eventing-timers.html
*User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
*Screen Resolution*: 1680 x 1050*Location*: https://docs.couchbase.com/server/6.0/eventing/eventing-examples-docexpiry.html *Referrer*: https://docs.couchbase.com/server/6.0/eventing/eventing-timers.html *User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36 *Screen Resolution*: 1680 x 1050
Description
on this page we are creating below function:
function OnUpdate(doc, meta) {
if (meta.expiration > 0 ) //do only for those documents that have a non-zero TTL
{
var expiry = new Date(meta.expiration);
// Compute 2 minutes from the TTL timestamp
var expiry = new Date(meta.expiration);
// Compute 2 minutes from the TTL timestamp
var twoMinsPrior = new Date(expiry.setMinutes(expiry.getMinutes()-2));
var context =
;
createTimer(DocTimerCallback, twoMinsPrior , meta.id, context);
.....
}
problem here is with the line var expiry = new Date(meta.expiration);
because new Date() takes milliseconds as an arguments, but meta.expiration stores TTL in seconds.
This example will always cause the timer to go off immediately.
Solution: we can do var expiry = new Date(meta.expiration * 1000); or store TTL in milliseconds.
Reporter: sushil kumar
E-mail: sushil_kumar1@homedepot.com