/** * Create the empty maps used by this class to do it's work. * * This functions contributes greatly to the performance of the class. Data maps that are named * can store and retrieve themselves at the time of the first request. That means they don't need to * be rebuilt every time, nor does all of the data have to be loaded and waiting for a request that * may never come. * * Because the geographic data managed by this class can be accessed hundreds or even * thousands of times when creating WPeC pages, moderate gains here can translate into * substantial gains in end user perfroamnce. For this reason this class will try to keep * the smaller frequently references data sets (data maps) intact and always available. * Potentially large data sets, such as the global list of all countires with all regions, * are only loaded when they are accessed. The WPSC_Data_Map provides the transpernet * loading and creating functions for these data sets. * * * @access private * * @static * * @since 3.8.14 * */ private static function _clean_data_maps() { /* * maps without names will be loaded with the core class, we maintain * a list as they are created */ self::$_maps_to_save_with_core_class = array(); // at 3.8.14 checked and this is about 1 KB of data if (is_a(self::$region_by_region_id, 'WPSC_Data_Map')) { self::$region_by_region_id->clear(); } else { self::$region_by_region_id = new WPSC_Data_Map(null, array(__CLASS__, '_create_region_by_region_id_map')); } self::$_maps_to_save_with_core_class['region_by_region_id'] = true; // at 3.14 checked and this is about 1 KB of data if (is_a(self::$region_code_by_region_id, 'WPSC_Data_Map')) { self::$region_code_by_region_id->clear(); } else { self::$region_code_by_region_id = new WPSC_Data_Map(null, array(__CLASS__, '_create_region_code_by_region_id_map')); } self::$_maps_to_save_with_core_class['region_code_by_region_id'] = true; // at 3.8.14 checked and this is about 1 KB of data if (is_a(self::$country_id_by_region_id, 'WPSC_Data_Map')) { self::$country_id_by_region_id->clear(); } else { self::$country_id_by_region_id = new WPSC_Data_Map(null, array(__CLASS__, '_create_country_id_by_region_id_map')); } self::$_maps_to_save_with_core_class['country_id_by_region_id'] = true; // at 3.8.14 checked and this is about 1 KB of data if (is_a(self::$country_id_by_iso_code, 'WPSC_Data_Map')) { self::$country_id_by_iso_code->clear(); } else { self::$country_id_by_iso_code = new WPSC_Data_Map(null, array(__CLASS__, '_create_country_id_by_iso_code_map')); } self::$_maps_to_save_with_core_class['country_id_by_iso_code'] = true; // at 3.8.14 checked and this is about 1 KB of data if (is_a(self::$country_code_by_country_id, 'WPSC_Data_Map')) { self::$country_code_by_country_id->clear(); } else { self::$country_code_by_country_id = new WPSC_Data_Map(null, array(__CLASS__, '_create_country_code_by_country_id')); } self::$_maps_to_save_with_core_class['country_code_by_country_id'] = true; // at 3.8.14 checked and this is about 2KB of data with 7 countries active, including US and CA if (is_a(self::$active_wpsc_country_by_country_id, 'WPSC_Data_Map')) { self::$active_wpsc_country_by_country_id->clear(); } else { self::$active_wpsc_country_by_country_id = new WPSC_Data_Map(null, array(__CLASS__, '_create_active_countries_map')); } self::$_maps_to_save_with_core_class['active_wpsc_country_by_country_id'] = true; // at 3.8.14 checked and this is about 1 KB of data if (is_a(self::$currencies, 'WPSC_Data_Map')) { self::$currencies->clear(); } else { self::$currencies = new WPSC_Data_Map(null, array(__CLASS__, '_create_currency_by_currency_code_map')); } self::$_maps_to_save_with_core_class['currencies'] = true; /* * maps with names can optionally reload thier data themselves when the first request * is processed, this class does not need to load/ re-load them because the WPSC_Data_Map * class takes care of that transparently. This goes a long way towards keeping the size of * of the transient used to cache this classes data small, making WPeC intitialization faster. */ // at 3.14 checked and this is about 3KB of data, this map isn't as frequently used so we will load it if it // needed if (is_a(self::$country_id_by_country_name, 'WPSC_Data_Map')) { self::$country_id_by_country_name->clear(); } else { self::$country_id_by_country_name = new WPSC_Data_Map('$country_id_by_country_name', array(__CLASS__, '_create_country_id_by_country_name_map')); } self::$_maps_to_save_with_core_class['country_id_by_country_name'] = false; // at 3.14 checked and this is about 23KB of data, not a big hit if there is a memory based object cache // but impacts perfomance on lower end (default) configurations that use the database to store transients if (is_a(self::$all_wpsc_country_by_country_id, 'WPSC_Data_Map')) { self::$all_wpsc_country_by_country_id->clear(); } else { self::$all_wpsc_country_by_country_id = new WPSC_Data_Map('$all_wpsc_country_by_country_id', array(__CLASS__, '_create_all_countries_map')); } self::$_maps_to_save_with_core_class['all_wpsc_country_by_country_id'] = false; }