function _field_file_cache in FileField 6.2
Same name and namespace in other branches
- 6.3 field_file.inc \_field_file_cache()
Internal cache, in order to minimize database queries for loading files.
4 calls to _field_file_cache()
- field_file_delete in ./
field_file.inc - Delete a field file and its database record.
- field_file_load in ./
field_file.inc - Load a file object from the database.
- field_file_save in ./
field_file.inc - Update an field item file. Delete marked items if neccessary and set new items as permamant.
- field_file_save_upload in ./
field_file.inc - Save a file upload to a new location. The source file is validated as a proper upload and handled as such. By implementing hook_file($op = 'insert'), modules are able to act on the file upload and to add their own properties to the file.
File
- ./
field_file.inc, line 176 - Common functionality for file handling CCK field modules.
Code
function _field_file_cache($file = NULL, $reset = FALSE) {
static $files = array();
// Reset internal cache.
if (is_object($reset)) {
// file object, uncache just that one
unset($files[$reset->fid]);
unset($files[$reset->filepath]);
}
else {
if ($reset) {
// TRUE, delete the whole cache
$files = array();
}
}
// Cache the file by both fid and filepath.
// Use non-copying objects to save memory.
if (isset($file)) {
$files[$file->fid] = $file;
$files[$file->filepath] = $file;
}
return $files;
}