mirror of
https://github.com/moodle/moodle.git
synced 2025-01-30 03:58:34 +01:00
Merge branch 'MDL-70368-cache-image-metadata' of https://github.com/brendanheywood/moodle
This commit is contained in:
commit
58a92364ed
@ -61,6 +61,7 @@ $string['cachedef_databasemeta'] = 'Database meta information';
|
||||
$string['cachedef_eventinvalidation'] = 'Event invalidation';
|
||||
$string['cachedef_externalbadges'] = 'External badges for particular user';
|
||||
$string['cachedef_fontawesomeiconmapping'] = 'Mapping of icons for font awesome';
|
||||
$string['cachedef_file_imageinfo'] = 'File image info eg dimensions';
|
||||
$string['cachedef_suspended_userids'] = 'List of suspended users per course';
|
||||
$string['cachedef_groupdata'] = 'Course group information';
|
||||
$string['cachedef_h5p_content_type_translations'] = 'H5P content-type libraries translations';
|
||||
|
@ -557,4 +557,14 @@ $definitions = array(
|
||||
'staticacceleration' => true,
|
||||
'ttl' => 1800,
|
||||
],
|
||||
|
||||
// Cache image dimensions.
|
||||
'file_imageinfo' => [
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true,
|
||||
'staticacceleration' => true,
|
||||
'canuselocalstore' => true,
|
||||
'staticaccelerationsize' => 100,
|
||||
],
|
||||
);
|
||||
|
@ -365,9 +365,18 @@ abstract class file_system {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hash = $file->get_contenthash();
|
||||
$cache = cache::make('core', 'file_imageinfo');
|
||||
$info = $cache->get($hash);
|
||||
if ($info !== false) {
|
||||
return $info;
|
||||
}
|
||||
|
||||
// Whilst get_imageinfo_from_path can use remote paths, it must download the entire file first.
|
||||
// It is more efficient to use a local file when possible.
|
||||
return $this->get_imageinfo_from_path($this->get_local_path_from_storedfile($file, true));
|
||||
$info = $this->get_imageinfo_from_path($this->get_local_path_from_storedfile($file, true));
|
||||
$cache->set($hash, $info);
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user