UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'lTuZ0sZYMBeF7oG+KTkE9mOf3kFt/aMArKE3N+1N+wk=' 
WHERE 
  key_id = '4be8646ea007a470c216e37011fa5b7e5b5789d3471c9aedf5f41e5d7b21457e' 
  AND (
    token = 'lTuZ0sZYMBeF7oG+KTkE9mOf3kFt/aMArKE3N+1N+wk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038