Using recno as a queue; alternative for consume()? - 02-01-2005 , 07:38 PM
I'm putting together an application which queues messages in the
case of a communications failure/delay. I want that queue to be
reliable in the case of failure (machine reboot, process crash,
etc) so I've been playing with Berkeley DB.
Ideally I'd use a Queue, but the messages are of variable length.
So, I've been using a Recno. Is there a better alternative?
Specifically, I want consume(). Is there a best practice to
simultaneously read (in insertion order) and delete a record from
a Recno db?
This will be a multi-treaded app (in Python, whee).
Marco E. Nicosia | http://www.escape.org/~marco/ | marco (AT) escape (DOT) org
Re: Using recno as a queue; alternative for consume()? - 02-03-2005 , 04:45 PM
One thing you can consider is to use a queue sized big enough for
your "typical" record and then use a btree to handle records which
are too big to fit in the queue indexed by their queue record number.
If most of your record are "typical" or less in size then you get
the advantage of the queue and little contention in the btree.
You would need to have some format information in your queue
data so you can tell what the real size of the record is and if you
have to read the btree.
RECNO has relatively poor concurancy since the whole tree
must be locked on updates so that record numbers can be
maintianed in the tree.