| @@ -317,11 +317,14 @@ | ||
| 317 | 317 | if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) { |
| 318 | 318 | $flush = true; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $cached_result = self::$_cache->get( $cache_key ); | |
| 321 | + $has_valid_cache = self::$_cache->has_valid( $cache_key, $expiration ); | |
| 322 | + $cached_result = $has_valid_cache ? | |
| 323 | + self::$_cache->get( $cache_key ) : | |
| 324 | + null; | |
| 322 | 325 | |
| 323 | - if ( $flush || ! self::$_cache->has_valid( $cache_key, $expiration ) ) { | |
| 326 | + if ( $flush || is_null( $cached_result ) ) { | |
| 324 | 327 | $result = $this->call( $path ); |
| 325 | 328 | |
| 326 | 329 | if ( ! is_object( $result ) || isset( $result->error ) ) { |
| 327 | 330 | // Api returned an error. |
| @@ -351,9 +354,11 @@ | ||
| 351 | 354 | } |
| 352 | 355 | } |
| 353 | 356 | } |
| 354 | 357 | |
| 355 | - self::$_cache->set( $cache_key, $result, $expiration ); | |
| 358 | + if ( is_numeric( $expiration ) ) { | |
| 359 | + self::$_cache->set( $cache_key, $result, $expiration ); | |
| 360 | + } | |
| 356 | 361 | |
| 357 | 362 | $cached_result = $result; |
| 358 | 363 | } else { |
| 359 | 364 | $this->_logger->log( 'Using cached API result.' ); |