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

Redis cache vs using memory directly

Redis is a remote data structure server. It is certainly slower than just storing the data in local memory (since it involves socket roundtrips to fetch/store the data). However, it also brings some interesting properties: Redis can be accessed by all the processes of your applications, possibly running on several nodes (something local memory cannot … Read more

Error: Redis connection to 127.0.0.1:6379 failed – connect ECONNREFUSED 127.0.0.1:6379

Redis runs in a seperate container which has seperate virtual ethernet adapter and IP address to the container your node application is running in. You need to link the two containers or create a user defined network for them docker network create redis docker run -d –net “redis” –name redis redis docker run -d -p … Read more

What does Redis do when it runs out of memory?

If you have virtual memory functionality turned on (EDIT: now deprecated), then Redis starts to store the “not-so-frequently-used” data to disk when memory runs out. If virtual memory in Redis is disabled (the default) and the maxmemory parameter is set (the default), Redis will not use any more memory than maxmemory allows. If you turn … Read more

how to store a complex object in redis (using redis-py)

Actually, you can store python objects in redis using the built-in module pickle. Here is example. import pickle import redis r = redis.StrictRedis(host=”localhost”, port=6379, db=0) obj = ExampleObject() pickled_object = pickle.dumps(obj) r.set(‘some_key’, pickled_object) unpacked_object = pickle.loads(r.get(‘some_key’)) obj == unpacked_object