每天缓存一次Amazon api数据
我创建了一个插件,通过亚马逊产品广告API从亚马逊获取一些信息 My函数根据itemsearch中使用的关键字k返回一个我希望每天缓存一次的信息数组(我在content to input关键字中使用一个短代码用于API调用) 有什么简单的解决办法可以实现吗每天缓存一次Amazon api数据,api,caching,wordpress,amazon,Api,Caching,Wordpress,Amazon,我创建了一个插件,通过亚马逊产品广告API从亚马逊获取一些信息 My函数根据itemsearch中使用的关键字k返回一个我希望每天缓存一次的信息数组(我在content to input关键字中使用一个短代码用于API调用) 有什么简单的解决办法可以实现吗 谢谢我通过Wordpress瞬态API()以以下方式解决了这个问题: if ( false === ( $product_info = get_transient( $kw ) ) ) { // It wasn't there, so reg
谢谢我通过Wordpress瞬态API()以以下方式解决了这个问题:
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 );
}
我通过Wordpress瞬态API()以以下方式解决了这个问题:
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 );
}
除了瞬态数据处理功能外,我们还可以使用自定义
WP_CRON
对象来计划数据提取。除了瞬态数据处理功能外,我们还可以使用自定义WP_CRON
对象来计划数据提取。