Improved return code handling

The "switch ($return['code'] == -1) {}" only returns true or false, not the integer you're expecting in the switch.
You should also check the null case when handling json_decode which means the php code of the apc flusher hasn't run.