Guys, I see little inconsistency. Imagine user does 1000 puts with near cache enabled. Then user does some gets() and size() returns 1000 + N, more gets() and size() is 1000 + M. This is a bit weird. Can we have nearSize() on public API? Any thoughts here?
As far as the original issue I would not bother with validity check on getting size and just return raw map size. --Yakov