Fixed offline topic support with wildcards in Mongodb.
Added memoization of topicPatterns.