Allow caching of HasChild and HasParent filters

Add cache and cacheKey options and related tests to HasChild and
HasParent filters.