[ATTENTION 0.16 commit] Fix memoize decorator for 0.16(same fix as in #6685)

Instead of cherry-picking all the commits from #6685, which also pulls unrelated code, we just fix the decorator and don't move it like in salt's develop.

This is the easiest solution to my cherry picking comments on #6685.

@basepi, @thatch45 is this acceptable? Committing directly to 0.16?