Gillingham have announced the signing of former Cardiff City midfielder Stuart O’Keefe on a two year deal.