UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'mQ1CvegZsI8049uF89/CjuszsFAGhHlAxbkIQ2lhyyk=' 
WHERE 
  key_id = '9aafb3acd44aeea50aa9cfb18b7947c8127715321d1c0e284d07069189cb997b' 
  AND (
    token = 'mQ1CvegZsI8049uF89/CjuszsFAGhHlAxbkIQ2lhyyk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00045