Open haohetao opened 3 years ago
The save() method is non-atomic, various problems can occur in highly concurrent operations. and it's inefficient.
Use the Lua script to implement the save operation, and primary keys must be unique.
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;
Sounds interesting. How about preparing a pull request with tests and implementation?
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.
Additional info