Matt Cain took a ball off his right foot and X-rays showed all was fine, then his right hamstring tightened as he tried to warm up for the seventh and that shortened his night. Cain pitched six scoreless innings to beat the Dodgers for the first time in nearly four years, and San Francisco snapped a four-game losing streak with a 2-1 win against Los Angeles on Monday night. Joe Panik hit a second-inning sacrifice fly off Hyun-Jin Ryu (0-4) in just the Giants' second victory in their last eight games.