/** * Clears the copy of the structured countries data we have cached * * @access public * * @since 3.8.14 * * @return none */ public static function clear_cache() { // delete anthing that is stored in the transient cache _wpsc_delete_transient(self::transient_name()); // when we clear the cached copy of the sdata, we also clear the resident copy of the data // so it is rebuilt and stays in sync self::_clean_data_maps(); self::$_initialized = false; self::$_dirty = false; }
/** * Retrieve a WP eCommerce Transient * Wrapper function to cover WordPress' get transient function. * Note: Initial reason for implmenting this was unusual derserialization errors coming from the APC * component when APC tries to deserialize a transient containing nested objects. This wrapper function * decodes the transient contents that were encoded so that APC will would try to deserialize it into * component objects. If the transient contents can not be decoded, the transient is deleted and the * function will return false as if the tranient never existed. * * @since 3.9.3 * @param string $transient Transient name. Expected to not be SQL-escaped. * @return mixed value of transient, false if transient did not exist */ function _wpsc_get_transient($transient) { $encoded_value = get_transient($transient); $value = false; if (false !== $encoded_value) { if (!empty($encoded_value) && is_string($encoded_value)) { $serialized_value = @base64_decode($encoded_value); if (is_string($serialized_value)) { $value = unserialize($serialized_value); } else { $value = false; } // if there was a transient, but it could not be decoded, we delete the transient to get back // to a working state if (false === $value) { _wpsc_delete_transient($transient); } } } return $value; }
/** * Save the map- if this map has been given a name it means we will save it as a transient when * requested or when we shutdown * * @access private * * @since 3.8.14 * * @return string a map name to uniquely identify this map so it can be saved and restored */ public function _save_map() { if ($this->_dirty) { // we sort the data before storing it, just to be neat ksort($this->_map_data); // if the map is named we will save it for next time, unless it is empty, we give an // expiration so that transient storage mechanisms can destroy the map if space is needed if (!empty($this->_map_name)) { if (!empty($this->_map_data)) { _wpsc_set_transient($this->_map_name, $this->_map_data, 13 * WEEK_IN_SECONDS); } else { _wpsc_delete_transient($this->_map_name); } } $this->_dirty = false; } }