UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'jw4k1LKpmKJjRw0NNwUj4WMvFjMuLqeXPYn8OliPJ+g=' 
WHERE 
  key_id = '304123aae745ec28616acc9723fde3e2f47d5e5cb730bb487cf082206297eaeb' 
  AND (
    token = 'jw4k1LKpmKJjRw0NNwUj4WMvFjMuLqeXPYn8OliPJ+g=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00136