Augh, I needed a hashmap in plpgsql last week! It's the worst. Best I could come up with was an awful hack in which I left stuff in a table with columns (key, val, invocation_code), where the third is a UUID specific to the invocation of the function. (Disgusting! I'm not proud of this.)
I'd pay (one upvote) for a blog post with a better way to do this. If one doesn't exist, this might call for a postgres extension.