Macing them is an awful idea. Your best defense is almost always going to be mobility, and the odds are pretty good you're going to mace yourself as well as them, and it's going to be difficult to pedal off fast if you're choking and/or vision impaired. Also, mace doesn't really incapacitate, and you might end up just making them crazier.
I've been threatened with an object that may or may not have been a gun while riding in NO in the 1980s. I did a uturn and rode away fast. There's no good going to come from a direct confrontation, and my primary strategy is to not put myself in situations where I could get cornered.
There's a path about a mile from my house that I don't go on at any time but rush hour because it seems to have become a hangout for drug users, and I think getting mugged there is a real possibility.