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
Post a Comment