4 ms·
A priority queue is usually an in-memory data structure. However, if you want to be able to schedule notifications in the distant future (e.g., a week or a year
by greenyoda 12y ago
A priority queue is usually an in-memory data structure. However, if you want to be able to schedule notifications in the distant future (e.g., a week or a year from today), you're going to need a stable and reliable way of storing them that can survive server re-starts, such as a database. Once your notifications are in a database, you can just run an SQL query that will select all the unsent notifications whose due date is between the last query time and the current date/time (after which you mark them as 'sent' or delete them). You'd want to have an index on the date/time field to allow for efficient retrieval.