See my testing below, this solution chokes with large hash.
In reply to Re^2: Delete all hash keys except for n of them by pg in thread Delete all hash keys except for n of them by Anonymous Monk