Added caching and database interface to trie

* Reimplemented caching for trie
* Reimplemented resetting and persisting trie