UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'n5f42tcvgSyY6yeg2sq3s+e1cMxUloieKcqblGYpB10=' 
WHERE 
  key_id = '54be541eef354873f6e967ca205c165e2b2d522f60a3dd43254ca6a1267a382d' 
  AND (
    token = 'n5f42tcvgSyY6yeg2sq3s+e1cMxUloieKcqblGYpB10=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034