This content has been marked as final. Show 2 replies
If you want a queue of variable-length records you could do the following:
1) Create a hash table holding your jpeg's.
The key should be a fixed-size record. (Perhaps the md5 of the jpeg or something).
The value would be the jpeg.
2) Store the key from (1) in a queue.
Perhaps you don't really need a queue. You could simply create a B-tree in which the key is a incrementing counter, and the value is the jpeg. To insert, fetch the DB_LASt itemfrom the B-tree, increment the key that you find there, and do a DB->put adding to the end of the tree To remove, fetch the DB_FIRST item from the B-tree. The advantage of the queue over this simple B-tree is that the queue has more concurrency. If your application doesn't need much concurrency, a simple B-tree solution might be good enough.
I'm not a real expert on the Berkeley DB, and maybe you can find better advice than mine... It would be great if someone who actually knows this stuff would confirm what I'm saying or contradict me!