[Catalyst] porting C::FastMmap to use Cache::Cache

toddrw69 at excite.com toddrw69 at excite.com
Sun Mar 13 08:45:59 CET 2005


toddrw69 at excite.com wrote:



>> But I still need some test code so I know when its ported :(

>

> Just create a small application using sessions.

>

> catalyst.pl MyApp

> cd MyApp

>

> Modify lib/MyApp.pm like this.

>

> use Catalyst qw/-Debug Session::FastMmap/;

>

> MyApp->action(

>

> '!begin' => sub {

> my ( $self, $c ) = @_;

> $c->log->debug( $c->session->{foo} ? "exists" : "doesn't exist" );

> $c->session->{foo} ||= 'bar';

> }

>

>);

>

> And run it.

>

> script/server.pl

>

> The log should say "exists" after the second request, otherwise

> you broke it. :)



Okay, this works great.



I just did:



    tie my %hash, 'Apache::Session::MySQL', undef, {

      Handle   => Role->db_Main,

      LockHandle => Role->db_Main

    };



(Role is a CDBI application of mine that I use()d in MyApp)



And then:



MyApp->action(

  '!default' => sub {

    my ( $self, $c ) = @_;

    $c->session->{foo} ||= 1;

    $c->response->output( $c->session->{foo} );

    $c->session->{foo} = $c->session->{foo} + 1;

  }

);



and made a couple other changes in C::FastMmap



and http://localhost:3000/ -> 1 -> Refresh -> 2 -> Refresh -> 3 ...



so Catalyst works on windows now.



Now I need to make this so we can all use it. With:



__PACKAGE__->mk_classdata('_session');



It looks like we could do:



use Catalyst qw/-Debug Session::ApacheSession/;



but how do I get startup config info in C::P::S::ApacheSession so I can say:



tie my %hash,

  delete($c->config->{session}{class}),

  undef, 

  $c->config->{session}

;



???



MyApp->config(

  # ...

  session => {

    class      => 'Apache::Session::MySQL',

    Handle     => $dbh,

    LockHandle => $dbh,

  }

);



???



TIA,



Todd W.



_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!



More information about the Catalyst mailing list