Added database caching of messages