Adding cache factory to prevent multiple queries