For pesto, place cashews in a bowl. Add boiling water to cover. Let stand 30 minutes; drain. In a blender or food processor combine cashews and the next six ingredients (through lemon juice).
Cook spaghetti according to package directions, adding green beans the last 2 minutes of cooking; drain, reserving 1 cup pasta cooking water. Return spaghetti to pan. Add pesto and cannellini beans; toss to coat. Add reserved pasta cooking water a little at a time to achieve desired texture, tossing to combine. Season with salt and black pepper. Sprinkle with pistachios and, if desired, crushed red pepper.