2009/4/19 Wout Mertens <[email protected]>:
> On Apr 19, 2009, at 1:56 PM, Elf wrote:
>
>> So, i have something like in view:
>>
>> if (doc.date_check < (new Date().getTime()/1000 - 2*60*60)) {
>>     emit('not checked', 1);
>> }
>>
>> As I understand, it's impossible to cache this view results, so this
>> view must be recounted on every call.
>> Am i right?
>
> No.
>
> This view will be calculated once and then the result is what it was until
> the document is changed and the view recalculated.

So, only first view calculating will be correct (new Date() returns
current date) and all next calls to this view will return incorrect
rows (because of outdate new Date() value in a view)?


>> Is there better idea to get document-level locking?
>
> Instead of "moving the view" you should "move the viewer".
>
> You should make a view showing only documents that are being worked on and
> emit the time at which work started. You can then get that view ordered in
> reverse, with the startkey set to to the time before which document
> processing should be retried.

Elegantly, thanks for idea!


-- 
----------------
Best regards
Elf
mailto:[email protected]

Reply via email to