in reply to Re^5: How to write time-related test without race conditions?
in thread How to write time-related test without race conditions?

If you're in overtime, if the cache has expired, then the test expectation must change from ->get('test') returns 1 to ->get('test') returns nothing
As I already said, this will make test to pass, but same effect will be from ok(1) because this test won't test things it's supposed to test in this case.

Failing the test because you're in overtime is a poorly written test.
Agreed, this is why I've posted this question.

But I now see the real problem, you're using EV to implement expiration, but that is something every caching module ( Cache/CHI .. ) knows how to do without an event loop; in short, the module has no use case
Modules which implement this without EV have to either lose noticeable amount of performance for cache housekeeping on each $cache->get() and $cache->set(), or require user to don't forget to manually call $cache->housekeeping() every few seconds (which usually mean adding this operation into many different places of code to guarantee it will be called often enough).

In event-based applications we can avoid both performance loss and chaos in code by simply using EV->timer to call housekeeping code internally in module. This is the use case for this module.

Replies are listed 'Best First'.
Re^7: How to write time-related test without race conditions?
by Anonymous Monk on May 15, 2012 at 03:07 UTC

    As I already said, this will make test to pass, but same effect will be from ok(1) because this test won't test things it's supposed to test in this case.

    lol