A Cambridgeshire man has been jailed for four years after police caught him throwing drugs out of his first-floor window.