add batch writes in cache.

In this PR, batch writes is added to the in memory cache as mentioned in #182
I would prefer this being in terms of time duration that maximum number of stats. If we had a lot of containers to track, we will end up writing often to the DB. I think we should re-use the code in influxdb driver here.