I'm trying to create a simple linkroll widget for displaying recent https://pinboard.in links via their API. To maximize loading speed, I want to cache the linklist in a widget field, as well as the timestamp when it was fetched last.
Now, if a defined time is over, I want to reload the link list via cURL and save it again in the widget field. How to do this from outside of the update() function?
My code:
// 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... */
}