protected function DatabaseRawBackend::prepareStorage in Supercache 8
Same name and namespace in other branches
- 2.0.x src/Cache/DatabaseRawBackend.php \Drupal\supercache\Cache\DatabaseRawBackend::prepareStorage()
Prepare data to be stored in the database.
Parameters
string $cid:
mixed $data:
Return value
array
1 call to DatabaseRawBackend::prepareStorage()
- DatabaseRawBackend::doSetMultiple in src/
Cache/ DatabaseRawBackend.php - Stores multiple items in the persistent cache.
File
- src/
Cache/ DatabaseRawBackend.php, line 204 - Contains \Drupal\supercache\Cache\DatabaseRawBackend.
Class
- DatabaseRawBackend
- Defines a default cache implementation.
Namespace
Drupal\supercache\CacheCode
protected function prepareStorage($cid, $data, $expire) {
$fields = array(
'cid' => $this
->normalizeCid($cid),
'expire' => $expire,
);
$fields['data_serialized'] = NULL;
$fields['data_string'] = NULL;
$fields['data_int'] = NULL;
$fields['data_float'] = NULL;
// We want to store numeric and string in a native way when this is possible.
if (is_bool($data) || is_int($data)) {
$fields['data_int'] = $data;
$fields['storage'] = 2;
}
elseif (is_float($data)) {
$fields['data_float'] = $data;
$fields['storage'] = 3;
}
elseif (is_string($data)) {
$fields['data_string'] = $data;
$fields['storage'] = 1;
}
else {
$fields['data_serialized'] = serialize($data);
$fields['storage'] = 0;
}
return $fields;
}