[Catalyst] Duplicate entries with C::P::Session::Store::DBIC and MySQL - new findings

Tobias Kremer list at funkreich.de
Tue Aug 26 13:18:18 BST 2008


Quoting Tobias Kremer <list at funkreich.de>:

> just wanted to inform you that switching from MyISAM to InnoDB for the
> session table does NOT solve the "duplicate entry" problem when
> using flash() :(

Just out of pure curiosity: Why is it that there are dedicated "flash:<hash>"
entries in the storage for the flash? Wouldn't the session be enough? I mean a
session is always established on the first request (logged-in or not), why not
just use it for the flash data (actually that's how other *cough* PHP
frameworks are doing it)? Something like this in my MyApp.pm seems to work
perfectly:

sub flash_msg {
    my( $c, $value ) = @_;
    if( $value ) {
        $c->session->{ '__flash__' } = $value;
    } else {
        return delete $c->session->{ '__flash__' };
    }
}

This should solve the race-condition and will reduce the queries per request
from FIVE(!) when using the flash mechanism down to 2.

What am I missing? :)

--Tobias



More information about the Catalyst mailing list