Check cache for count functions that return zero.

Some of our count functions were previously setting counts of zero
correctly, but the functions themselves were not referencing the cache
properly when the count returned zero.  This led to unnecessary database
queries and we hate extra queries!

This commit addresses the problem and adds unit tests.

Props r-a-y, boonebgorges.

Fixes #6012.

git-svn-id: https://buddypress.svn.wordpress.org/trunk@9231 cdf35c40-ae34-48e0-9cc9-0c9da1808c22