diff options
author | Christian Schneider | 2018-02-14 14:41:23 +0100 |
---|---|---|
committer | Christian Schneider | 2018-02-14 14:41:23 +0100 |
commit | 36572cde8de29b47f94f74b9812afa443bd02567 (patch) | |
tree | b7f5e39f521296d359792451d035a53ce8860036 | |
parent | b1b253ed346932c5cb0d37b559bd69a29d6c0cc6 (diff) | |
download | itools-36572cde8de29b47f94f74b9812afa443bd02567.tar.gz itools-36572cde8de29b47f94f74b9812afa443bd02567.tar.bz2 itools-36572cde8de29b47f94f74b9812afa443bd02567.zip |
Add support for precalculated cachefilename
-rw-r--r-- | it_url.class | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/it_url.class b/it_url.class index cd0edb0..3a8cc41 100644 --- a/it_url.class +++ b/it_url.class @@ -382,11 +382,12 @@ static function get_cache_dir($p) /** - * Construct a local file name to cache an URL. Named args: + * Construct a local file name to cache an URL. Takes language into account. Named args: * @param $p['url'] remote url to get - * @param $p['cachedir'] directory to store cache files in, @see get_cache_dir - * @param $p['data'] POST data array with key-value pairs - * @param $p['id'] If you need more than one type of cache (e.g. different maxage) you can specify an id + * @param $p['cachedir'] directory to store cache files in, @see get_cache_dir + * @param $p['cachefilename'] Use this filename instead of calculating your own if this is given + * @param $p['data'] POST data array with key-value pairs + * @param $p['id'] If you need more than one type of cache (e.g. different maxage) you can specify an id */ static function get_cache_filename($p) { @@ -394,7 +395,7 @@ static function get_cache_filename($p) $p = array('url'=>$p); $p['cachedir'] = it_url::get_cache_dir($p); - $filename = md5(T_lang() . $p['url'] . ($p['headers'] ? serialize($p['headers']) : "") . ($p['data'] ? serialize($p['data']) : "")); + $filename = $p['cachefilename'] ?: md5(T_lang() . $p['url'] . ($p['headers'] ? serialize($p['headers']) : "") . ($p['data'] ? serialize($p['data']) : "")); return $p['cachedir'] . "/" . substr($filename, 0, 2) . "/$filename"; } |