Efficiently access most recently accessed MongoDB entries? -


i'm making service similar requirements url shortener; need store bunch of unique hashes , corresponding strings. tricky part need order them access date can retrieve last 10 accessed entries (and next 10 after that, etc.)

everything i've come far grossly inefficient. what's best way store queue this?

one solution: add accessed_at field update when url accessed. index it, can find urls sorted accessed_at field.

you alternately use capped collection holds accessed urls; each time url accessed, insert capped collection. give rolling window of recent accesses. won't deduplicate, though, if url particularly popular, show in list multiple times.


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -