[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
Tue Dec 20 23:27:09 CET 2022


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

--- Comment #8 from David Cook <dcook at prosentient.com.au> ---
(In reply to David Gustafsson from comment #7)
> I missed the code example you posted, I don't think that method would work
> as I think you missed the case where we get a cache miss and need to
> retrieve the value. 

I've implied that the "cache" method looks up the value by using the key. Take
the following example:

return $self->cache({ key => 'is_expired' }) if $param->{cache};

In the "cache" method, you'd check the cache and if there is a cache miss,
you'd do something like the following:

my $accessor_method = $args->{key};
my $value = $self->$accessor_method();

You don't need to use a closure like in your example. It's very minimal code.
(Note it would also live in Koha::Object and be inherited into Koha::Patron and
other friends.)

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


More information about the Koha-bugs mailing list