I’m trying to implement a page-views-counter with Rails and memcached. Every time I render a page, through rails I increase a memcached key (key.incr is atomic). My main worry is the possibility where this key gets expired or deleted from memcached before I update my DB record. Even if I visit all the keys with frequency greater than their expiration time, memcached might delete a key in the meantime because of full memory.
Any suggestions?
Thank you
Dimitris
I would go with redis as a memcached replacement. It’s perfect for realtime stats. It gives you the speed and atomic increments that you want, plus it persists. Problem solved.