save data to db from cache