CHI
view release on metacpan or search on metacpan
Returns a boolean indicating whether this is a subcache.
=item subcache_type( )
Returns the type of subcache as a string, e.g. 'l1_cache' or 'mirror_cache'.
Can only be called if I<is_subcache> is true.
=item parent_cache( )
Returns the parent cache (weakened to prevent circular reference). Can only be
called if I<is_subcache> is true.
=back
=head2 Developing new kinds of subcaches
At this time, subcache behavior is hardcoded into CHI::Driver, so there is no
easy way to modify the behavior of existing subcache types or create new ones.
We'd like to make this more flexible eventually.
lib/CHI/Driver/Role/HasSubcaches.pm view on Meta::CPAN
package CHI::Driver::Role::HasSubcaches;
$CHI::Driver::Role::HasSubcaches::VERSION = '0.61';
use Moo::Role;
use CHI::Types qw(:all);
use MooX::Types::MooseLike::Base qw(:all);
use Hash::MoreUtils qw(slice_exists);
use Log::Any qw($log);
use Scalar::Util qw(weaken);
use strict;
use warnings;
my @subcache_nonoverride_params =
qw(expires_at expires_in expires_variance serializer);
sub _non_overridable {
my $params = shift;
if ( is_HashRef($params) ) {
if (
lib/CHI/t/Driver.pm view on Meta::CPAN
use strict;
use warnings;
use CHI::Test;
use CHI::Test::Util
qw(activate_test_logger cmp_bool is_between random_string skip_until);
use CHI::Util qw(can_load dump_one_line write_file);
use Encode;
use File::Spec::Functions qw(tmpdir);
use File::Temp qw(tempdir);
use List::Util qw(shuffle);
use Scalar::Util qw(weaken);
use Storable qw(dclone);
use Test::Warn;
use Time::HiRes qw(usleep);
use base qw(CHI::Test::Class);
# Flags indicating what each test driver supports
sub supports_clear { 1 }
sub supports_expires_on_backend { 0 }
sub supports_get_namespaces { 1 }
lib/CHI/t/Driver.pm view on Meta::CPAN
$check->( sub { $cache->get('a') } );
}
sub test_no_leak : Tests {
my ($self) = @_;
my $weakref;
{
my $cache = $self->new_cache();
$weakref = $cache;
weaken($weakref);
ok( defined($weakref) && $weakref->isa('CHI::Driver'),
"weakref is defined" );
}
ok( !defined($weakref), "weakref is no longer defined - cache was freed" );
}
{
package My::CHI;
$My::CHI::VERSION = '0.61';
our @ISA = qw(CHI);
( run in 0.631 second using v1.01-cache-2.11-cpan-65fba6d93b7 )