}
}
if ($useCURL) {
- $c = new curl($request);
+ $c = new curl(array('cache'=>true));
$c->setopt(array('CURLOPT_FOLLOWLOCATION'=>true));
$xml = $c->get($request);
/*
}
$this->debug = false;
if(!empty($options['cookie'])) {
- if(is_file($options['cookie'])) {
+ if(file_exists($options['cookie'])) {
$this->cookie = $options['cookie'];
}
}
+ if(!empty($options['cache'])) {
+ $this->cache = new repository_cache;
+ }
$this->resetopt();
}
public function resetopt(){
$this->cleanopt();
// create curl instance
$curl = curl_init($url);
+ $this->setopt(array('url'=>$url));
// reset before set options
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this,'formatHeader'));
var_dump($this->header);
}
+ if($this->cache && $ret = $this->cache->get($this->options)) {
+ return $ret;
+ } else {
+ $ret = curl_exec($curl);
+ if($this->cache) {
+ $this->cache->set($this->options, $ret);
+ }
+ }
- $ret = curl_exec($curl);
$this->info = curl_getinfo($curl);
$this->error = curl_error($curl);
$this->php_version = explode(".", $this->php_version[0]);
require_once($CFG->dirroot.'/repository/curl.class.php');
- $this->curl = new curl;
+ $this->curl = new curl(array('cache'=>true));
}
function enableCache($type, $connection, $cache_expire = 600, $table = 'flickr_cache')
<?php
require_once('../config.php');
require_once('lib.php');
+$CFG->repository_cache_expire = 120;
$id = optional_param('id', PARAM_INT);
$action = optional_param('action', '', PARAM_RAW);
if(!$repository = $DB->get_record('repository', array('id'=>$id))) {