[Koha-bugs] [Bug 28436] Cache relatively static info that is used often and on many pages (instead of fetching from DB)

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Sep 9 04:39:51 CEST 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28436

David Cook <dcook at prosentient.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcook at prosentient.com.au

--- Comment #3 from David Cook <dcook at prosentient.com.au> ---
(In reply to Nick Clemens from comment #2)
> We can definitely add more plugins here.
> 
> This feels a bit hacky, however, it reduces to a single lookup per page,
> avoids problems with cache coherence and is readable

Actually, it looks like there might be a cache coherence problem, since the
our-scoped variable will exist for the life of the process. You could wind up
with stale data if data is cached, the worker stays alive, data is changed in
the staff interface, and then requests are sent to that original worker.

I'd suggest just caching at the request-level. 

I would suggest creating a new() method which sets an object variable with the
required data. According to
http://www.template-toolkit.org/docs/modules/Template/Plugin.html, the new()
method will be called in the USE directive. 

This means that at template processing time you'll get 1 lookup, and then you
can reuse that data for the life of that request. 

There are even cache examples on that TT link above.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list