Open
Description
What steps will reproduce the problem?
The save() method is non-atomic, various problems can occur in highly concurrent operations.
and it's inefficient.
What's expected?
Use the Lua script to implement the save operation, and primary keys must be unique.
What do you get instead?
Refactoring the insert method in ActiveRecord class.
$luaScript = <<<EOF
if redis.call('EXISTS', $key) == 0 then
redis.call('RPUSH', $prefixKey, $pkKey)
end
redis.call('HMSET', $setArgs)
return 1
EOF;
Additional info
Q | A |
---|---|
Yii vesion | 2.0.40 |
PHP version | 8.0.1 |
Operating system | docker |