public function DatabaseRawBackend::counter in Supercache 8
Same name and namespace in other branches
- 2.0.x src/Cache/DatabaseRawBackend.php \Drupal\supercache\Cache\DatabaseRawBackend::counter()
Add an increment (can be negative) to the stored cache data. Only works for stored numeric data.
Parameters
string $cide: The cache ID or array of ID's.
int $increment: The amount to increment or decrement.
int $default: Default value.
Overrides CacheRawBackendInterface::counter
1 call to DatabaseRawBackend::counter()
- DatabaseRawBackend::counterMultiple in src/
Cache/ DatabaseRawBackend.php - Add an increment (can be negative) to the stored cache data. Only works for stored numeric data.
File
- src/
Cache/ DatabaseRawBackend.php, line 352 - Contains \Drupal\supercache\Cache\DatabaseRawBackend.
Class
- DatabaseRawBackend
- Defines a default cache implementation.
Namespace
Drupal\supercache\CacheCode
public function counter($cid, $increment, $default = 0) {
$try_again = FALSE;
try {
// The bin might not yet exist.
$this
->doCounter($cid, $increment, $default);
} catch (\Exception $e) {
// If there was an exception, try to create the bins.
if (!($try_again = $this
->ensureBinExists())) {
// If the exception happened for other reason than the missing bin
// table, propagate the exception.
throw $e;
}
}
// Now that the bin has been created, try again if necessary.
if ($try_again) {
$this
->doCounter($cid, $increment, $default);
}
}