Simplified code, and support dynamic message cache total count by configuration.

Configuration fixed in index.js.