From 6b1c4d00f7f5cf300c7f824d304471853f4b4e01 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 10 Jun 2022 08:11:28 +0100 Subject: [PATCH] Bug 29623: (QA follow-up) Add POD to Koha::Cache::Lite Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Cache/Memory/Lite.pm | 52 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Koha/Cache/Memory/Lite.pm b/Koha/Cache/Memory/Lite.pm index 21c6b121d7..ebdb0431d4 100644 --- a/Koha/Cache/Memory/Lite.pm +++ b/Koha/Cache/Memory/Lite.pm @@ -41,34 +41,84 @@ use Modern::Perl; use base qw(Class::Accessor); our %L1_cache; - our $singleton_cache; + +=head2 get_instance + +This gets a shared instance of the lite cache, set up in a very default +way. The lite cache is an in memory only cache that's automatically flushed +for every request. + +=cut + sub get_instance { my ($class) = @_; $singleton_cache = $class->new() unless $singleton_cache; return $singleton_cache; } +=head2 get_from_cache + + my $value = $cache->get_from_cache($key); + +Retrieve the value stored under the specified key in the cache. + +The retrieved value is a direct reference so should not be modified. + +=cut + sub get_from_cache { my ( $self, $key ) = @_; return $L1_cache{$key}; } +=head2 set_in_cache + + $cache->set_in_cache($key, $value); + +Save a value to the specified key in the cache. + +=cut + sub set_in_cache { my ( $self, $key, $value ) = @_; $L1_cache{$key} = $value; } +=head2 clear_from_cache + + $cache->clear_from_cache($key); + +Remove the value identified by the specified key from the lite cache. + +=cut + sub clear_from_cache { my ( $self, $key ) = @_; delete $L1_cache{$key}; } +=head2 all_keys + + my @keys = $cache->all_keys(); + +Returns an array of all keys currently in the lite cache. + +=cut + sub all_keys { my ( $self ) = @_; return keys %L1_cache; } +=head2 flush + + $cache->flush(); + +Clear the entire lite cache. + +=cut + sub flush { my ( $self ) = @_; %L1_cache = (); -- 2.39.5