public function clearUsageCache($clearDatabase, $groups = null)
{
$ltm_translations = $this->getTranslationsTableName();
if (!$groups || $groups === '*') {
$this->usageCache();
$this->usageCache = [];
$this->usageCacheIsDirty = true;
$this->saveUsageCache();
if ($clearDatabase) {
$this->getConnection()->affectingStatement(<<<SQL
UPDATE {$ltm_translations} SET was_used = 0 WHERE was_used <> 0
SQL
);
}
} elseif ($this->usageCache()) {
$this->usageCache();
if (!is_array($groups)) {
$groups = [$groups];
}
foreach ($groups as $group) {
if (array_key_exists($group, $this->usageCache)) {
unset($this->usageCache[$group]);
$this->usageCacheIsDirty = !!$this->persistentPrefix;
}
if ($clearDatabase) {
$this->getConnection()->affectingStatement(<<<SQL
UPDATE {$ltm_translations} SET was_used = 0 WHERE was_used <> 0 AND (`group` = ? OR `group` LIKE ? OR `group` LIKE ?)
SQL
, [$group, 'vnd:%.' . $group, 'wbn:%.' . $group]);
}
}
$this->saveUsageCache();
}
}