Ability to update views when doc is deleted through couchbase expiration
We need a way to detect when CouchBase deletes doc through implicit meta expiration. In such a case, we would like to use a view and emit some data in expired doc as key and value. We will use this to process view data to process report and some related info.
If above is not possible, are there alternatives such as below
- I see that view has access to current meta and current doc in context. Is it possible to read existing view key and update them. Ex - see the commented line
function (doc, meta) {
// newData = get(meta.expiration) + doc.someId
emit(meta.expiration, newData;
}
Is emit(key, value), a set operation implying overwrite. In your example to list recent sessions using views, expiration is used as key in view emits. This wouldn't work if there are more than one session expiring in the same second. Is resolution precision epoch, seconds or milliseconds?
Thanks in advance
Raghu
Hello,
This is currently not possible, the view will be only updated when the expiration is "pushed" on disk and the index updated (you can force it with stale=false when calling the view).
You can control the process that delete expired item on disk using the "expiry pager" process. You can find some information here:
http://www.couchbase.com/docs/couchbase-devguide-2.0/about-ttl-values.html
You can control this process using the "exp_pager_stime" parameter:
http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-admin-cbepc...
regards
Tug
@tgrall