Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Data::Queue::Persistence experience

by SimonClinch (Chaplain)
on May 13, 2011 at 16:39 UTC ( #904697=note: print w/ replies, xml ) Need Help??


in reply to Data::Queue::Persistence experience

If o/s supports fifos, then they are better than using a database, e.g.

package persque; sub new { bless { FIFO => shift()}; # must be given an existent fifo file or + creatable filename } sub install { # create persistent queue my $self = shift; mkfifo $self -> { FIFO } or die "$!: " . $self -> { FIFO } . "\n"; } sub enqueue { my $self = shift; my @items = @_; chomp @items; open $fh, '>' . $self -> { FIFO } or die "$!: " . $self -> { FIFO } . "\n"; print $fh (map { $_ . "\n" } @_); close $fh; } sub dequeue { my $self = shift; open $fh, $self -> { FIFO } or die "$!: " . $self -> { FIFO } . "\n"; my $r = <$fh>; close $fh; $r; } 1;

One world, one people


Comment on Re: Data::Queue::Persistence experience
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://904697]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-11-26 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (162 votes), past polls