mirror of
https://github.com/we-promise/sure.git
synced 2026-06-06 03:09:02 +00:00
Make upsert atomic
This commit is contained in:
@@ -74,7 +74,9 @@ class Setting < RailsSettings::Base
|
||||
if value.nil?
|
||||
where(var: dynamic_key).destroy_all
|
||||
else
|
||||
super(dynamic_key, value)
|
||||
# Use upsert for atomic insert/update to avoid race conditions
|
||||
upsert({ var: dynamic_key, value: value.to_yaml }, unique_by: :var)
|
||||
clear_cache
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user