Changeset 6633 for sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/utilities/class-currency-xrt-client.php
- Timestamp:
- 02/14/2018 01:00:05 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/utilities/class-currency-xrt-client.php
r6596 r6633 79 79 public function get_rates( $date ) { 80 80 $rates = array(); 81 $cache_key = 'wc_currency_rates_' . strtotime( $date ); 81 82 82 83 try { … … 88 89 } 89 90 90 $cached_rates = $this->get_cached_rates( $date);91 $cached_rates = get_transient( $cache_key ); 91 92 92 93 if ( false !== $cached_rates ) { … … 107 108 $rates = array_map( 'floatval', $rates ); 108 109 109 $this->cache_rates( $date, $rates);110 set_transient( $cache_key, $rates, MONTH_IN_SECONDS ); 110 111 111 112 return $rates; … … 212 213 return $data; 213 214 } 214 215 /**216 * Check for cached currency exchange rates for a particular date and return them if available.217 *218 * @todo Add object and/or database caching.219 *220 * @param \DateTime $date The date to retrieve rates for.221 *222 * @return array|bool223 */224 protected function get_cached_rates( \DateTime $date ) {225 if ( isset( $this->cache[ $date->format( 'Y-m-d' ) ] ) ) {226 return $this->cache[ $date->format( 'Y-m-d' ) ];227 }228 229 return false;230 }231 232 /**233 * Cache the currency exchange rates for a particular date.234 *235 * @todo Add object and/or database caching.236 *237 * @param \DateTime $date The date of the rates to be cached.238 * @param array $rates The rates to be cached.239 *240 * @return void241 */242 protected function cache_rates( \DateTime $date, $rates ) {243 $this->cache[ $date->format( 'Y-m-d' ) ] = $rates;244 }245 215 }
Note: See TracChangeset
for help on using the changeset viewer.