我正在尝试创建一个简单的linkroll小部件来显示最近的https://pinboard.in 通过API链接。为了最大限度地提高加载速度,我想在一个小部件字段中缓存链接列表,以及最后获取它的时间戳。
现在,如果定义的时间结束了,我想通过cURL重新加载链接列表,并将其再次保存在widget字段中。如何从update()函数外部执行此操作?
我的代码:
// display widget
function widget($args, $instance) {
extract( $args );
// get widget title
$title = apply_filters(\'widget_title\', $instance[\'title\']);
// get options
$token = $instance[\'token\'];
$tags = $instance[\'tags\'];
$unread = $instance[\'unread\'];
$range = $instance[\'range\'];
// update linklist based on cache validity
$isvalid = $this->_check_valid_cache( $instance[\'expires\'], $range );
if ( $isvalid === TRUE ) {
$cache = $instance[\'cache\'];
$expires = $instance[\'expires\'];
} else {
$cache = $this->_get_recent( $token );
$expires = $isvalid;
/* --> does not work!! */
$this->update($instance, $instance);
}
/* ...display widget... */
}