Commit 4866ce3c by savvot

yii\redis\ActiveRecord::deleteAll() refactoring - no need to write to socket 2…

yii\redis\ActiveRecord::deleteAll() refactoring - no need to write to socket 2 times when nothing found
parent b17ddcf7
...@@ -236,17 +236,14 @@ class ActiveRecord extends BaseActiveRecord ...@@ -236,17 +236,14 @@ class ActiveRecord extends BaseActiveRecord
$db = static::getDb(); $db = static::getDb();
$attributeKeys = []; $attributeKeys = [];
$pks = self::fetchPks($condition); $pks = self::fetchPks($condition);
if(!$pks) return 0;
$db->executeCommand('MULTI'); $db->executeCommand('MULTI');
foreach ($pks as $pk) { foreach ($pks as $pk) {
$pk = static::buildKey($pk); $pk = static::buildKey($pk);
$db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]); $db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]);
$attributeKeys[] = static::keyPrefix() . ':a:' . $pk; $attributeKeys[] = static::keyPrefix() . ':a:' . $pk;
} }
if (empty($attributeKeys)) {
$db->executeCommand('EXEC');
return 0;
}
$db->executeCommand('DEL', $attributeKeys); $db->executeCommand('DEL', $attributeKeys);
$result = $db->executeCommand('EXEC'); $result = $db->executeCommand('EXEC');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment