Fasted way to increment a persistent counter from a node.js app?
Problem
I have a search engine written in node.js/express that is currently not logging any statistics, and I'd like to start keeping track of # of queries per day. So I just need a persistent counter that I can increment each time a query is submitted. (I'll write a cron job to store it and clear it out at the end of the day, that's not relevant to this question).
There are obviously many ways to do this, so my one requirement is that it be very fast. Is redis overkill for this? Is there a simpler solution that would still be very fast?
Solution
Literally fastest solution is using Memcache.
Create a counter object which has counters for each query, e.g.
counter = {
'_q:whatever': 1,
'_q:something else': 123
}
Then on page load add or increment keys in Counter. And then using cron pull Counter and parse all keys, update in your DB.
Discussion
View additional discussion.