Blog
Your better off using memcached, or some sort of shared memory storage if you want to gain caching peformance for typical web application design patterns
]]>It has a gotcha, though. There is no way to reset the “cache” from the outside. You have to write it into each and every memoizing function explicitly.
In your example, this could become important if, for instance, you suddenly want to use GetArticleById in a very long-running command-line script (e.g. a nightly cron job), where you might end up calling it thousands of times in the same run. Pretty soon, you would hit memory allocation limits, stale data and what have we.
In such cases, you will either have to maintain two versions of the function or extend it with some cache manipulation parameters.
]]>I mainly have used it when programming in JavaScript, but, sure, the concept is useful when using another languages.
Kind Regards
]]>