Fixes #307: Only set cache when it's an array