dbTalk Databases Forums  

Queue Peek

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Queue Peek in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
yoav.aviram@gmail.com
 
Posts: n/a

Default Queue Peek - 05-27-2007 , 10:52 AM






I am working on implementing a persistent queue system based on
Berkeley DB queue access method.
For my new queue implementation I need to implement a 'peek' method.
This method should return the next available record from the head of
the queue, but not delete it.

The desired behavior is much like doing a 'get' with 'DB_CONSUME' or
'DB_CONSUME_WAIT', but without the CONSUME part.
How would I go about implementing such behavior?

For now I only see two alternatives - both having problems:
1. I can use a cursor starting at the head of the queue, and working
my way down (using 'DB_NEXT').
The problem with this method is that in parallel to the 'peek'
operations, pop operations are done (actually more like delete).
This causes the tail of the queue to become a hotspot - locking the
cursor.
Also I have cases where the cursor skips records despite the use of
' DB_INORDER'.
2. I can use a 'get' operation with 'DB_CONSUME_WAIT', and then
rollback the transaction.
This seems both inelegant and IO wasteful.

Any ideas?
- Thanks, Yoav.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.