summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class11
1 files changed, 4 insertions, 7 deletions
diff --git a/it_url.class b/it_url.class
index 513255d..1a21fb4 100644
--- a/it_url.class
+++ b/it_url.class
@@ -333,12 +333,8 @@ function get($p=null, $timeout=5)
*/
function get_cache_dir($p)
{
- $result = $p['cachedir'];
-
- if (!it::match('^/', $result))
- $result = $GLOBALS['ULTRAHOME'] . "/var/urlcache/$result";
-
- return rtrim($result, "/");
+ $p += array('cachedir' => $GLOBALS['ULTRAHOME'] . "/var/urlcache");
+ return rtrim($p['cachedir'] . "/" . $p['id'], "/");
}
@@ -364,6 +360,7 @@ function get_cache_filename($p)
* Requires webserver writeable directory in $p['cachdedir']. Params in associative array p:
* @param $p['url'] url to get
* @param $p['cachedir'] directory to store cache files in, @see get_cache_dir
+ * @param $p['id'] If you need more than one type of cache (e.g. different maxage) you can specify an id
* @param $p['timeout'] timeout in seconds, default 10. fractions allowed
* @param $p['maxage'] maximum age of cache entries in seconds, default 86400
* @param $p['cleanbefore'] maximum daytime when attempting cleanup, default 7200
@@ -376,9 +373,9 @@ function get_cache($p = array())
{
$p += array('timeout' => 10, 'maxage' => 86400, 'cleanbefore' => 7200, 'safety' => 1, 'it_error' => array());
$p['totaltimeout'] = $p['timeout'];
+ $path = it_url::get_cache_filename($p); # Must be before changing cachedir below
$p['cachedir'] = it_url::get_cache_dir($p);
- $path = it_url::get_cache_filename($p);
@mkdir($p['cachedir']);
@mkdir(dirname($path));
$age = file_exists($path) ? (time() - @filemtime($path)) : 0;