implement cache for Dijkstra results