I am working with flask and redis. I use the rom redis orm to manage some mildly complex data structures. I want to use a queue of model objects, with the ability to push or pop objects off either end.
I have the following rom model:
class A(rom.Model):
url = rom.String(required=True, unique=True)()
t = rom.String()
delete_at = rom.Float(index=True)
created_at = rom.Float(default=time.time, index=True)
I see that at the command line when I run obj._columns (with obj being a single instance of class A), that there is an id field. My first thought on how to approach this is to order by id:
queue = A.get_by(id).
This would allow easy addition to the back of the queue, by setting:
obj.id = len(queue)+1
But I'm not sure how to insert into the 0 element of the list which would require renumbering of the ids of the entire list.
Am I on the right track here? What is the best way to implement a queue?