function _field_file_cache in FileField 6.3
Same name and namespace in other branches
- 6.2 field_file.inc \_field_file_cache()
Internal cache, in order to minimize database queries for loading files.
5 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 from the database.
- field_file_save in ./
field_file.inc - Save a node file. Delete items if necessary and set new items as permanent.
- field_file_save_file in ./
field_file.inc - Save a file into a file node after running all the associated validators.
- 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 280 - 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 (!empty($file->fid)) {
$files[$file->fid] = $file;
$files[$file->filepath] = $file;
}
return $files;
}