long (final long cacheCapacityInPages, final int numberOfDifferentPagesRequested, final int totalRequestsCount) { final long expectedPagesAllocated; if (cacheCapacityInPages >= numberOfDifferentPagesRequested) { expectedPagesAllocated = numberOfDifferentPagesRequested; } else { final double cacheEffectiveness = Math.min(cacheCapacityInPages * 1.0 / numberOfDifferentPagesRequested, 1); expectedPagesAllocated = cacheCapacityInPages + (long)((totalRequestsCount - cacheCapacityInPages) * (1 - cacheEffectiveness)); } return expectedPagesAllocated; }