Implement memoization in cfkey.

This patch fixes issues #26.
Merge pull request #26 from Igalia/issue-26-fix-cfkey

Fix n² complexity in cfkey