It's all about the signing bonus and the length.
Maholmes did a monster deal that made him very affordable for 5 years. At that point they will rework the contract to reduce the cap hit and pay him another big bonus.
There isn't any real cap in football. It's all about cash.