Redis key expiration testing

I was wondering if anyone has a smart way to test behavior after the redis key has expired. I essentially create a small redis redundant cache for my application and would like to check what happens after the redis key expires.

I use rspec as a testing framework. I tried using Timecop to change the time during testing, but realized that this would only affect the operation of the test frame, and not the external redis server.

I can set TTL to 1 and then use sleep (1), but I would prefer not to introduce sleep in my tests.

Does anyone have a good way to test this?

+5
source share
2 answers

, redis . , redis , , , , redis.

redis_client.should_recieve(:ttl).with(key).then_return(-1)

redis_client.should_recieve(:get).with(key).then_return(nil)
0

All Articles