Hi Mr. Brand,
thanks a lot for Tie::Hash::DBD. I use it for web session handling,
storing the session records in a SQLite-DB.
After inspecting your code, I didn't find an API to make Tie::Hash::DBD
AutoCommit-ing. Currently I use the following workaround:
$tied_obj->{dbh}{AutoCommit} = 1;
But anyway, the STORE and DELETE routine aren't ready
for concurrent usage. I miss transactions around the
following code-blocks:
sub STORE
{
my ($self, $key, $value) = @_;
my $k = $self->{asc} ? unpack "H*", $key : $key;
my $v = $self->_stream ($value);
Show quoted text
>>> TRANSACTION BEGIN
$self->EXISTS ($key)
? $self->{upd}->execute ($v, $k)
: $self->{ins}->execute ($k, $v);
Show quoted text>>> TRANSACTION COMMIT
} # STORE
sub DELETE
{
my ($self, $key) = @_;
$self->{asc} and $key = unpack "H*", $key;
Show quoted text>>> TRANSACTION BEGIN
$self->{sel}->execute ($key);
my $r = $self->{sel}->fetch or
Show quoted text>>> TRANSACTION COMMIT
return;
$self->{del}->execute ($key);
Show quoted text>>> TRANSACTION COMMIT
$self->_unstream ($r->[0]);
} # DELETE
Similar is necessary if you access the tied hash via:
each, keys or values
sub FIRSTKEY
{
my $self = shift;
Show quoted text>>> TRANSACTION BEGIN
$self->{key} = $self->{dbh}->selectcol_arrayref ("select
$self->{f_k} from $self->{tbl}");
@{$self->{key}} or
Show quoted text>>> TRANSACTION COMMIT)
return;
if ($self->{asc}) {
$_ = pack "H*", $_ for @{$self->{key}};
}
pop @{$self->{key}};
} # FIRSTKEY
sub NEXTKEY
{
my $self = shift;
@{$self->{key}} or
Show quoted text>>> TRANSACTION COMMIT
return;
pop @{$self->{key}};
} # FIRSTKEY
What do you mean, would this be possible. Perhaps as a new
Tie::Hash::DBD::Transactional ????
Best Regards
Charly Gaissmaier