Arduino Playground has some pretty well developed pages with code.
Need to start with Ether's questions, how many pulse/rev and what RPM rate you are looking to sense. Looks like many of the solutions use interrupts, which may be limited on the Arduino, so you may have significant limitations on rate it can process.
http://playground.arduino.cc/Main/RotaryEncoders