diff options
author | Christian Schneider | 2009-06-24 14:49:26 +0000 |
---|---|---|
committer | Christian Schneider | 2009-06-24 14:49:26 +0000 |
commit | a9264e2231dfd4013e6c5824ac0f9fceee9c99c0 (patch) | |
tree | 16d9ac04531c0d967df1ef6fb3e0a07c93ffe709 /it_url.class | |
parent | a916788b6ba0986cb3a424f4cd4dc60bb110b8bc (diff) | |
download | itools-a9264e2231dfd4013e6c5824ac0f9fceee9c99c0.tar.gz itools-a9264e2231dfd4013e6c5824ac0f9fceee9c99c0.tar.bz2 itools-a9264e2231dfd4013e6c5824ac0f9fceee9c99c0.zip |
Added new parameter 'id' to specify cache type
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 11 |
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; |