UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'RLW0pmrHD8W2PbB71s7iFkerzKSv6sem4FVG4a14anE=' 
WHERE 
  key_id = '38ac45a03a5f114b3c4a509cd2d7dbd2dbcf96156c119ed03135fd3adc175773' 
  AND (
    token = 'RLW0pmrHD8W2PbB71s7iFkerzKSv6sem4FVG4a14anE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00046