[codec-memcache] Avoid memory leak when encoding the key

fixed the other part in my code and this should fix it in the memcache codec