Use cache to accelerate hash calculation.