mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-16 20:05:14 +02:00
New cache system with subdirectories
This commit is contained in:
parent
e67062d9cf
commit
f17377e6de
7 changed files with 83 additions and 86 deletions
|
@ -823,15 +823,13 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
|
|||
$scaled = $mtch[1];
|
||||
$i = fetch_url($scaled);
|
||||
|
||||
$cache = get_config('system','itemcache');
|
||||
if (($cache != '') and is_dir($cache)) {
|
||||
$cachefile = $cache."/".hash("md5", $scaled);
|
||||
$cachefile = get_cachefile(hash("md5", $scaled));
|
||||
if ($cachefile != '')
|
||||
file_put_contents($cachefile, $i);
|
||||
}
|
||||
|
||||
// guess mimetype from headers or filename
|
||||
$type = guess_image_type($mtch[1],true);
|
||||
|
||||
|
||||
if($i) {
|
||||
$ph = new Photo($i, $type);
|
||||
if($ph->is_valid()) {
|
||||
|
|
|
@ -102,18 +102,8 @@ function poller_run(&$argv, &$argc){
|
|||
// clear old cache
|
||||
Cache::clear();
|
||||
|
||||
// clear item cache files if they are older than one day
|
||||
$cache = get_config('system','itemcache');
|
||||
if (($cache != '') and is_dir($cache)) {
|
||||
if ($dh = opendir($cache)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
$fullpath = $cache."/".$file;
|
||||
if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - 86400))
|
||||
unlink($fullpath);
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
// clear old item cache files
|
||||
clear_cache();
|
||||
|
||||
$manual_id = 0;
|
||||
$generation = 0;
|
||||
|
@ -128,7 +118,7 @@ function poller_run(&$argv, &$argc){
|
|||
$restart = true;
|
||||
$generation = intval($argv[2]);
|
||||
if(! $generation)
|
||||
killme();
|
||||
killme();
|
||||
}
|
||||
|
||||
if(($argc > 1) && intval($argv[1])) {
|
||||
|
|
|
@ -962,13 +962,11 @@ if(! function_exists('prepare_body')) {
|
|||
function prepare_body($item,$attach = false) {
|
||||
|
||||
$a = get_app();
|
||||
call_hooks('prepare_body_init', $item);
|
||||
call_hooks('prepare_body_init', $item);
|
||||
|
||||
$cache = get_config('system','itemcache');
|
||||
|
||||
if (($cache != '')) {
|
||||
$cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']);
|
||||
$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
|
||||
|
||||
if (($cachefile != '')) {
|
||||
if (file_exists($cachefile))
|
||||
$s = file_get_contents($cachefile);
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue