faeldt / redis-mock

Node.js redis client mock
112 stars 157 forks source link

Expiring method causing test issues #30

Open download13 opened 10 years ago

download13 commented 10 years ago

The method used for expiring values seems to be causing some issues. A lot of care must be taken to make things like setInteval and setTimeout not cause problems with the fake timers provided by sinon.

I propose a change to a lazy expiration system. It should solve the problems with sinon, and the problem of values living up to 100 milliseconds after they were supposed to expire. Plus it would allow the deletion of a large chunk of complicated code from the RedisMock constructor.

I can send a pull request if nobody else wants to do it just now.

download13 commented 10 years ago

More generally, I'm looking to help improve this library a bit so I can use it for a project, but it seems like there's some test problems right now. A bunch of tests fail on my system and Travis doesn't seem to be handling it all that well either.

Would anyone mind if I went through and tried to clean it out? At least to the point where the tests reliably pass on Travis.

faeldt commented 10 years ago

Please go ahead. I'll review and accept PRs ASAP.

On Saturday, August 9, 2014, Erin Dachtler notifications@github.com wrote:

More generally, I'm looking to help improve this library a bit so I can use it for a project, but it seems like there's some test problems right now. A bunch of tests fail on my system and Travis doesn't seem to be handling it all that well either.

Would anyone mind if I went through and tried to clean it out? At least to the point where the tests reliably pass on Travis.

— Reply to this email directly or view it on GitHub https://github.com/faeldt/redis-mock/issues/30#issuecomment-51661179.

brantwedel commented 9 years ago

+1 Redis itself uses a lazy timer system @download13 What is the status on this ... I was thinking of doing the exact same thing.

Currently I just scan all the keys and clear all the _expire timeouts after the test, but deleted keys cause problems since they don't clear timeouts on DEL.

brantwedel commented 9 years ago

Interim solution, clear timeouts on DEL and FLUSHDB: #48