Implement memoization in cfkey.

This patch fixes issues #26.