Hi Jon,

I did this test and it passes. It looks like the correct class is used
(Poet::Cache), but when the object is constructed, something goes wrong
with how Poet's configuration is passed to its constructor and we end up
with default cache driver - CHI::Driver::File - being used.

I tried to add this to PSGIHandler.pm tests and I modified them like this
(I'd send a .diff but its such a small change that its pointless):

I added these statements to $poet conf initializer at the beginning of the
file:

*'cache.defaults.driver' => 'Memory',*
*'cache.defaults.global' =>  1,*

Then I changed test_cache fund like this:

sub test_cache : Tests {
    my $self = shift;

    my $expected_root_dir = $poet->root_dir . "/data/cache";
    *my $expected_driver = $poet->conf->get("cache.defaults.driver");*
  $self->try_psgi_comp(
        path => '/cache.mc',
        src  => '
chi_root_class: <% $m->cache->chi_root_class %>
root_dir: <% $m->cache->root_dir %>
*driver: <% $m->cache->driver_class %>*
',
        expect_content => "
chi_root_class: Poet::Cache
root_dir: $expected_root_dir
*driver: CHI::Driver::$expected_driver*
",
    );
}

This is the result:

not ok 19 - /cache.mc - content

#   Failed test '/cache.mc - content'

#   at MyTest.pm line 62.

#   (in MyTest->test_cache)

#          got: 'chi_root_class: Poet::Cache

# root_dir: /tmp/Poet-jGQp/data/cache

# driver: CHI::Driver::File'

#     expected: 'chi_root_class: Poet::Cache

# root_dir: /tmp/Poet-jGQp/data/cache

# driver: CHI::Driver::Memory'

So even though I set default cache to be Memory, its initialized as File
storage, everything else is fine (chi_root_class and root_dir).

It seems like Poet::Cache->cache_defaults are not loaded at the time Mason
creates its Cache class? I will try to debug it further, I'm not yet sure
if I'm doing something wrong or the problem is with order of initialization
- I will let you know if I find something.




On 16 January 2014 13:41, Jonathan Swartz <swa...@pobox.com> wrote:

> In Poet::Mason it sets the default cache_root_class to Poet's Cache class:
>
> method get_options ($class:) {
>     my %defaults = (
>         cache_root_class => $poet->app_class('Cache'),
>
> There is a Poet test for this in Poet::t::PSGIHandler (test_cache). Is
> this test passing for you?
>
> Jon
>
> On Jan 13, 2014, at 4:42 AM, Kamil Niechajewicz <
> k.niechajew...@firma.bankier.pl> wrote:
>
> Hello,
>
> We wanted to start using Poet::Cache in our application and discovered a
> really weird problem. Following manual from here (
> http://search.cpan.org/~jswartz/Poet-0.10/lib/Poet/Cache.pm), we need to
> configure default cache store - I did it for Memcached, in global.cfg:
>
> cache:
>     defaults:
>          driver: Memcached
>          servers: ["127.0.0.1:11211"]
>
> Then I should just start my app and use $m->cache in Mason components,
> right? The problem is - whenever I use $m->cache, it uses File driver
> instead of Memcached. I checked and it looks like Poet::Cache works well
> when used from scripts or Perl modules (it loads correct cache object), but
> for Mason components its always default File cache.
>
> This led me to Mason::Plugins::Cache and I realized that I have no idea
> how this class works together with Poet's caching. It seems that the
> problem lies somewhere in between - Poet's configuration is not passed
> correctly to Mason::Plugin, but why?
> ------------------------------------------------------------------------------
> 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
>
>
>


-- 

Kamil Niechajewicz

Kierownik ds. Rozwoju

*Biuro serwisu Bankier.pl* www.bankier.pl

ul. Mokotowska 1, 00-640 Warszawa

kom. +48 601 951 495, fax +48 22 378 99 06

e-mail: k.niechajew...@bankier.pl <k.niechajew...@firma.bankier.pl>


Grupa Bankier.pl Sp. z o.o. z siedzibą w Poznaniu, 60-166 Poznań, przy ul.
Grunwaldzkiej 182, wpisana do rejestru przedsiębiorców prowadzonego przez
Sąd Rejonowy Poznań - Nowe Miasto i Wilda w Poznaniu, VIII Wydział
Gospodarczy Krajowego Rejestru Sądowego pod numerem KRS 0000258659, o
kapitale zakładowym w wysokości 70 100 zł, posiadająca numer identyfikacji
podatkowej NIP 972-113-50-60, Regon: 300308237.
------------------------------------------------------------------------------
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