+subtest 'Koha::Cache::Memory::Lite' => sub {
+ plan tests => 6;
+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
+
+ # test fetching an item that isnt in the cache
+ is( $memory_cache->get_from_cache("not in here"),
+ undef, "fetching item NOT in cache" );
+
+ # test fetching a valid item from cache
+ $memory_cache->set_in_cache( "clear_me", "I AM MORE DATA" );
+ $memory_cache->set_in_cache( "dont_clear_me", "I AM MORE DATA22" );
+ ; # overly large expiry time, clear below
+ is(
+ $memory_cache->get_from_cache("clear_me"),
+ "I AM MORE DATA",
+ "fetching valid item from cache"
+ );
+
+ # test clearing from cache
+ $memory_cache->clear_from_cache("clear_me");
+ is( $memory_cache->get_from_cache("clear_me"),
+ undef, "fetching cleared item from cache" );
+ is(
+ $memory_cache->get_from_cache("dont_clear_me"),
+ "I AM MORE DATA22",
+ "fetching valid item from cache (after clearing another item)"
+ );
+
+ #test flushing from cache
+ $memory_cache->set_in_cache( "flush_me", "testing 1 data" );
+ $memory_cache->flush;
+ is( $memory_cache->get_from_cache("flush_me"),
+ undef, "fetching flushed item from cache" );
+ is( $memory_cache->get_from_cache("dont_clear_me"),
+ undef, "fetching flushed item from cache" );
+};
+
+subtest 'Koha::Caches' => sub {
+ plan tests => 8;
+ my $default_cache = Koha::Caches->get_instance();
+ my $another_cache = Koha::Caches->get_instance('another_cache');
+ $default_cache->set_in_cache('key_a', 'value_a');
+ $default_cache->set_in_cache('key_b', 'value_b');
+ $another_cache->set_in_cache('key_a', 'another_value_a');
+ $another_cache->set_in_cache('key_b', 'another_value_b');
+ is( $default_cache->get_from_cache('key_a'), 'value_a' );
+ is( $another_cache->get_from_cache('key_a'), 'another_value_a' );
+ is( $default_cache->get_from_cache('key_b'), 'value_b' );
+ is( $another_cache->get_from_cache('key_b'), 'another_value_b' );
+ $another_cache->clear_from_cache('key_b');
+ is( $default_cache->get_from_cache('key_b'), 'value_b' );
+ is( $another_cache->get_from_cache('key_b'), undef );
+ $another_cache->flush_all();
+ is( $default_cache->get_from_cache('key_a'), 'value_a' );
+ is( $another_cache->get_from_cache('key_a'), undef );
+};
+