UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'P9M7aYor7vYmfckOBwrirHV72BsIP3wRlSs3SJH4aP8=' 
WHERE 
  key_id = '8d3a998031ca816683869226abb40f6d12fba751c13a9471d52424bf453de021' 
  AND (
    token = 'P9M7aYor7vYmfckOBwrirHV72BsIP3wRlSs3SJH4aP8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044