Fix #87. Add checkCacheStructure.

Add checkCacheStructure for exception handling and rebuild the whole
cache structure if a table is missing.