Is non-blocking Redis pubsub possible?

If you’re thinking of non-blocking, asynchronous processing, you’re probably using (or should use) asynchronous framework/server. if you’re using Tornado, there is Tornado-Redis. It’s using native Tornado generator calls. Its Websocket demo provides example on how to use it in combination with pub/sub. if you’re using Twisted, there is txRedis. There you also have pub/sub example. … Read more

Redis + ActionController::Live threads not dying

A solution I just did (borrowing a lot from @teeg) which seems to work okay (haven’t failure tested it, tho) config/initializers/redis.rb $redis = Redis.new(:host => “xxxx.com”, :port => 6379) heartbeat_thread = Thread.new do while true $redis.publish(“heartbeat”,”thump”) sleep 30.seconds end end at_exit do # not sure this is needed, but just in case heartbeat_thread.kill $redis.quit end … Read more

Can I set global TTL in redis?

No, Redis doesn’t have a notion of a global/default TTL and yes, you do have to set it for each key independently. However, depending on your requirements and on what you’re trying to do, there may be other ways to achieve your goal. Put differently, why do you need it? For example, if you want … Read more

Jest tests leaking due to improper teardown

As suggested in the warning, add –detectOpenHandles option to jest’s script in package.json file: “scripts”: { “test”: “jest –watchAll –detectOpenHandles” } Dont forget to stop then start the server ! This solution can work whatever your problem. But, according to your case, your problem is coming from the redis connection. You need to close redis … Read more

Cache invalidation strategy

Invalidate the cache during the Update stage is a viable approach, and was extremely used in the past. You have two options here when the UPDATE happens: You may try to set the new value during update operation, or Just delete the old one and update during a read operation. If you want an LRU … Read more

How to connect to a Redis container using Docker Compose?

The issue is that redis is “variable” that will be interpolated in the Dockerfile. ENV REDIS_URL redis:6379 But the Redis URL should start with the literal redis. So, the fix is updating the docker compose: redis_db: image: redis:3.2.8 The desired config is: REDIS_URL=redis://redis_db:6379 Thanks to BMitch and Andy Shinn for helping me figure this out.