Milestone: Cache distance

Add: Store cache data in database.
Improved: Robust and speed.