Ok, I found something interesting, it happens in cache method in
Mason::Plugin::Cache::Component.pm:

method cache ($class:) {
    if ( !@_ && $class->cache_memoized ) {
        return $class->cache_memoized;
    }
    my $cache_root_class = $class->cache_root_class;
    my %options = ( %{ $class->cache_defaults }, @_ );
    if ( !exists( $options{namespace} ) ) {
        $options{namespace} = $class->cache_namespace;
    }
   * my $cache = $cache_root_class->new(%options);*
    if ( !@_ ) {
        $class->cache_memoized($cache);
    }
    return $cache;
}

I bolded section that creates Poet::Cache and passes %options hash to it,
which in my case contains some Mason's defaults. I dumped it and thats what
it contains:

*%options =*

{
          'namespace' => '/test.mc',
          'root_dir' => '/var/www/bankier-portal/data/cache',
          'driver' => 'File'
};


Then I dumped $cache_root_class->config, and this is what I get:


*$cache_root_class->config =*

{
          'namespace' => {},
          'defaults' => {
                          'global' => 1,
                          'driver' => 'Memory'
                        }
};


This means that Poet's config is loaded correctly and stored in CHI
base class method *config*. But then when
$cache_root_class->new(%options) is called, defaults get passed there
(first dump above). Then there is clash between driver from Mason
defaults and Poet conf, and somehow the one from Mason has bigger
priority (it happens in CHI.pm around line 80.


This is what ends up as final constructor params for CHI cache class:


{   *'driver_class' => 'CHI::Driver::File',*
    'namespace' => '/test.mc',
    'root_dir' => '/var/www/bankier-portal/data/cache',
    *'global' => 1,*
    'chi_root_class' => 'Poet::Cache'
}


You can see that *driver_class* is wrong - its File instead of Memory,
but *global *is still there. So it merged configs, but driver supplied
by Mason won over driver supplied by Poet's conf. This explains why
when I tried Memcached driver, I had "servers" parameter hanging in
dump, while driver was still File.


Any idea how to fix this? Obviously problem is with options passed to
new() from Mason::Plugin::Cache::Component, as they cloak the ones we
get from config.
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to