[Koha-bugs] [Bug 32476] Add caching for relatively expensive patron methods

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Dec 21 16:56:30 CET 2022


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

--- Comment #10 from David Gustafsson <glasklas at gmail.com> ---
Ok! My bad, now think I understand. There is an issue with your suggestion
though, if I'm not still misinterpreting parts of it. The current behavior is
to clear the cache if the accessor method is called without the cache parameter
set to true. This is if course slightly ugly imho, as not at all obvious
without looking at the code. The idea is that calling the accessor uncached
should be done either when caching doesn't matter, or when the cached value
could be stale. If the cache was not cleared subsequent cached calls could
return a stale value, resulting in subtle bugs that could be difficult to track
down. An alternative could be to always enter values into the cache regardless
if caching is enabled or not, but this is also not what one would expect and it
feels more intuitive that caching in that case is skipped altogether.

I just can't see how to this behavior using your suggestion, but if there is
something I'm missing perhaps you could provide a full example.

I created a new version which avoids the code duplication of the caching
behavior based on the previous version but instead using a class property for
storing cached values as you suggested. It's a little bit more opaque than the
original version, but the upside is that caching behavior is generalized and
the code duplication can be avoided.

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


More information about the Koha-bugs mailing list