Index: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/utilities/class-currency-xrt-client.php
===================================================================
--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/utilities/class-currency-xrt-client.php (revision 6596)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/utilities/class-currency-xrt-client.php (revision 6633)
@@ -79,4 +79,5 @@
public function get_rates( $date ) {
$rates = array();
+ $cache_key = 'wc_currency_rates_' . strtotime( $date );
try {
@@ -88,5 +89,5 @@
}
- $cached_rates = $this->get_cached_rates( $date );
+ $cached_rates = get_transient( $cache_key );
if ( false !== $cached_rates ) {
@@ -107,5 +108,5 @@
$rates = array_map( 'floatval', $rates );
- $this->cache_rates( $date, $rates );
+ set_transient( $cache_key, $rates, MONTH_IN_SECONDS );
return $rates;
@@ -212,34 +213,3 @@
return $data;
}
-
- /**
- * Check for cached currency exchange rates for a particular date and return them if available.
- *
- * @todo Add object and/or database caching.
- *
- * @param \DateTime $date The date to retrieve rates for.
- *
- * @return array|bool
- */
- protected function get_cached_rates( \DateTime $date ) {
- if ( isset( $this->cache[ $date->format( 'Y-m-d' ) ] ) ) {
- return $this->cache[ $date->format( 'Y-m-d' ) ];
- }
-
- return false;
- }
-
- /**
- * Cache the currency exchange rates for a particular date.
- *
- * @todo Add object and/or database caching.
- *
- * @param \DateTime $date The date of the rates to be cached.
- * @param array $rates The rates to be cached.
- *
- * @return void
- */
- protected function cache_rates( \DateTime $date, $rates ) {
- $this->cache[ $date->format( 'Y-m-d' ) ] = $rates;
- }
}