Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

sharing DBMs

by marvell (Pilgrim)
on Oct 02, 2002 at 14:37 UTC ( [id://202288]=perlquestion: print w/replies, xml ) Need Help??

marvell has asked for the wisdom of the Perl Monks concerning the following question:

Is the only way to write share a dbm file to use the built in locking of higher versions and retie before read?

That is to say, is there a way of rereading the dbm instead of doing tie again?

--
Steve Marvell

Replies are listed 'Best First'.
Re: sharing DBMs
by mp (Deacon) on Oct 02, 2002 at 15:59 UTC
    I don't fully understand your question, but MLDBM::Sync will handle DBM locking for you.
      Having read more into it, it appears my question is:

      Is there a perl module that allows you to us the concurrent data model (many read, one write) model for Berkeley DB in a tie way?

      That is to say, as one process writes, the other can read and it's there.

      --
      Steve Marvell

        After reading more, and playing, here it is:

        #!/usr/bin/perl -w use strict; use BerkeleyDB; use Data::Dumper; my $env = new BerkeleyDB::Env( -Home => '/home/steve/test', -Flags => DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL ) || die "env error: $! $BerkeleyDB::Error"; my $db = (tie my %hash, 'BerkeleyDB::Hash', -Filename => 'db2.bdb', -Env => $env, -Flags => DB_CREATE) || die "db error: $! $BerkeleyDB::Error"; while (<>) { $hash{$1} = $2 if (/(.*)=(.*)/); print Dumper \%hash; } undef $db; untie %hash;

        --
        Steve Marvell

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://202288]
Approved by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-20 15:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found