Apache-Session-SQLite3

 view release on metacpan or  search on metacpan

lib/Apache/Session/Store/SQLite3.pm  view on Meta::CPAN


    local $self->{dbh}->{RaiseError} = 1;

    if (!defined $self->{insert_sth}) {
        $self->{insert_sth} = $self->{dbh}->prepare_cached(qq[
             INSERT INTO $self->{'table_name'} (id, a_session, LastUpdated)
                  VALUES (?, ?, ?)
        ]);
    }

    $self->{insert_sth}->bind_param(1, $session->{data}->{_session_id}, SQL_CHAR);
    $self->{insert_sth}->bind_param(2, $session->{serialized}, SQL_BLOB);
    $self->{insert_sth}->bind_param(3, time, SQL_INTEGER);

    $self->{insert_sth}->execute;
    $self->{insert_sth}->finish;
}

sub update {
    my $self    = shift;
    my $session = shift;
 
    $self->connection($session);

lib/Apache/Session/Store/SQLite3.pm  view on Meta::CPAN

    local $self->{dbh}->{RaiseError} = 1;

    if (!defined $self->{update_sth}) {
        $self->{update_sth} = $self->{dbh}->prepare_cached(qq[
             UPDATE $self->{'table_name'}
                SET a_session = ?, LastUpdated = ?
              WHERE id = ?
        ]);
    }

    $self->{update_sth}->bind_param(1, $session->{serialized}, SQL_BLOB);
    $self->{update_sth}->bind_param(2, time, SQL_INTEGER);
    $self->{update_sth}->bind_param(3, $session->{data}->{_session_id}, SQL_CHAR);

    foreach my $count (1..600) {
        local $@;
	eval { $self->{update_sth}->execute; 1 } and last;
	sleep 1;
    }
    $self->{update_sth}->finish;
}

1;



( run in 1.655 second using v1.01-cache-2.11-cpan-2398b32b56e )