On Thu, Feb 9, 2012 at 11:35 AM, Paul <paul.a@aandc.org> wrote:
At 10:18 AM 2/9/2012 +0000, MJ Ray wrote:
Tomas Cohen Arazi <tomascohen@gmail.com>
[snip]
2) Memoization in Koha Do we plan to use memoization in the mid/long-term? Or are we thinking of a more abstract set of 'cache' utilities which provide an interface to memcached?
Using memoization is nice, clean and simple. It has the disadvantage that caching is done in an implicit way, and there are hidden problems (read side-effects) that have to be taken into account. For example,
Is there a good list of the example disadvantages somewhere?
Have other projects made this decision faced with similar circumstances, and can we see their reasoning?
Disclaimer: my knowledge of memoization dates back to FORTRAN (fluid dynamics, harmonics and orbital calcs and was mostly used in conjunction with polynomial functions.)
Is there enough repetitive math in Koha to justify memoization? I've been looking at caching (specifically memcached 1.4.13) for faster access to "text" (as opposed to calculated numeric values) in the general sense of page rendering and search results which I see as the bulk of what is returned (and therefore time cost) by a client request. The biggest problem that I appear to be facing at this point is coordinating the zebra cronjob with a discreet cache. The more static Koha files (pl, tt, inc) have not [yet] posed difficulties.
I retained caching for the sql content again based on "text" versus "math results", as most examples of memoization appear to be primarily used for math functions (see for example <http://brooke.blogs.sqlsentry.net/2010/02/caching-and-memoization.html>)
If I'm way off-track from what you folks have been working on, please point me in the right direction. I'd be more than happy to look into an example of a specific case where you have felt that memoization might be advantageous.
You are right on asking for clarification as Koha is using Memoization in a different way as usual. Memoization is normally used to trade space (in the stack) for computing time (doing the math). This ussually happens trough the life of the main loop of the app. In this case, Koha has been using memoization libs that have a persistent storage (memcached) that lives until they reach their TTL that caches the results of function calls as a way to avoid coding the cache stuff: the Memoize lib does a trick that creates a wrapper around your functions so you don't need to worry about that stuff. Hence, we are using memoization libs, to make the implementation of caching easier. Regards To+