1

I created a plugin to get some info from Amazon though Amazon product advertising API.

My function returns an array of info that I would like to cache once a day based on the keywordk used in the itemsearch (I use a shortcode in the content to input keyword for the API call)

Is there any simple solution to make it happen?

Thanks

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Zioprog
  • 11
  • 4
  • Apart from transient data handling functions, we may use custom `WP_CRON` object to schedule data fetch. –  Feb 07 '17 at 23:26

1 Answers1

0

I solved the issue through the Wordpress Transient API (http://codex.wordpress.org/Transients_API) in the following way:

if ( false === ( $product_info = get_transient( $kw ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$product_info = my_function_to_getinfo( $kw );      
set_transient( $kw, $product_info, 24 * HOUR_IN_SECONDS );
}
Zioprog
  • 11
  • 4