Data::Queue::Persistent - Perisistent database-backed queue
use Data::Queue::Persistent; my $q = Data::Queue::Persistent->new( table => 'persistent_queue', # name to save queues in dsn => 'dbi:SQLite:dbname=queue.db', # dsn for database to save queues id => 'testqueue', # queue identifier cache => 1, noload => 1, # don't load saved queue automatically max_size => 100, # limit to 100 items ); $q->add('first', 'second', 'third', 'fourth'); $q->remove; # returns 'first' $q->remove(2); # returns ('second', 'third') $q->empty; # removes everything
This is a simple module to keep a persistent queue around. It is just a normal implementation of a queue, except it is backed by a database so that when your program exits the data won't disappear.
None by default.
Creates a new persistent data queue object. This will also initialize the database storage, and load the saved queue data if it already exists.
dsn: DSN for database connection.
dbh: Already initialized DBI connection handle.
id: The ID of this queue. You can have multiple queues stored in the same table, distinguished by their IDs.
user: The username for database connection (optional).
pass: The password for database connection (optional).
cache: Enable caching of the queue for speed. Not reccommended if multiple instances of the queue will be used concurrently. Default is 0.
table: The table name to use ('persistent_queue' by default).
noload: Don't load queue data when initialized (only applicable if caching is used)
max_size: Limit the queue to max_size, with the oldest elements falling off
Adds a list of items to the queue.
Removes $count (1 by default) items from the queue and returns them. Returns value if no $count specified, otherwise returns an array of values.
Gets $length elements starting at offset $offset
Returns all elements in the queue. Does not modify the queue.
Returns count of elements in the queue.
Removes all elements from the queue.
Any data structures book.
Mischa Spiegelmock, <firstname.lastname@example.org>
Copyright (C) 2007 by Mischa Spiegelmock
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.