I am currently loading an XML HTTP Request into an array and then caching it although sometimes the site I pull the data from isn't the most reliable and I get back blank page or not everything filled out. One way of fixing this I thought would to be make sure that the array has the same or more amount of data in the array and then caching it for an hour. Now here is my issue when ever it array doesn't have the data I don't have the previous cache giving me an error on the cached variable. Do I know if I understand caching right? Can I cache a variable and only overwrite if given a certain condition? Anyhelp would be great. My thought would be to store the data in mysql and then query it if the variable doesn't go through.if ( $checksize>=8 ){
weather_result = wp_cache_get( 'my_result' );
if ( false == $weather_result ) {
$weather_result= $insert_array;
wp_cache_add( 'weather_cache', $weather_result,$flag = '',$expire = 0);
}
}
Now the checksize is just an array which counts the number of elements in the array. I would only like to update this when it has all the information.