Blog

Comments on: Improving performance with return values caching http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/ LAMP Web Developer Wed, 16 Mar 2011 13:53:48 +0000 http://wordpress.org/?v=2.9.1 hourly 1 By: David http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/comment-page-1/#comment-6 David Mon, 16 Feb 2009 03:28:19 +0000 http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/#comment-6 Thistechnique will only work if the script in question is making many requests to the same function in the lifetime of a single server request. The function and variable scope only will last the lifetime of the current script. The next user/request gains no advantage of the caching in your model. 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 Thistechnique will only work if the script in question is making many requests to the same function in the lifetime of a single server request. The function and variable scope only will last the lifetime of the current script. The next user/request gains no advantage of the caching in your model.

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

]]>
By: Jean-Michel Feurprier http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/comment-page-1/#comment-5 Jean-Michel Feurprier Fri, 06 Feb 2009 01:10:03 +0000 http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/#comment-5 Exactly ! I will try to make another post in a near future about more advanced caching techniques. Exactly ! I will try to make another post in a near future about more advanced caching techniques.

]]>
By: Jesper Vingborg Andersen http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/comment-page-1/#comment-4 Jesper Vingborg Andersen Thu, 05 Feb 2009 15:57:13 +0000 http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/#comment-4 Yeah, it is a very neat trick that is used in many projects, such as Drupal. A real lifesaver at times. 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. Yeah, it is a very neat trick that is used in many projects, such as Drupal. A real lifesaver at times.

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.

]]>
By: Jean-Michel Feurprier http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/comment-page-1/#comment-3 Jean-Michel Feurprier Thu, 05 Feb 2009 15:14:27 +0000 http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/#comment-3 Thanks a lot for the information, I didn't know there was a name for it ! Thanks a lot for the information, I didn’t know there was a name for it !

]]>
By: Marcos Silva Pereira http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/comment-page-1/#comment-2 Marcos Silva Pereira Thu, 05 Feb 2009 14:54:44 +0000 http://blog.jmfeurprier.com/2009/02/04/improving-performance-with-return-values-caching/#comment-2 This technique has a name: Memoization: http://en.wikipedia.org/wiki/Memoization I mainly have used it when programming in JavaScript, but, sure, the concept is useful when using another languages. Kind Regards This technique has a name: Memoization: http://en.wikipedia.org/wiki/Memoization

I mainly have used it when programming in JavaScript, but, sure, the concept is useful when using another languages.

Kind Regards

]]>