had to revert to two queries (max and count) per cache key, my approach didn't work out