Closed Sija closed 10 years ago
Hey @Sija, check out #94 for more info on this. The tl;dr is that Redis doesn't keep track of when elements were added or removed from SETs, so it's not really possible unless I were to completely change which underlying data structures are used here (and I'm not terribly interested in doing that right now). Sorry!
How about the returning ids in their insertion order (or rather reverse)? I reckon this should solve the problem without the need of touching underlying data structure.
On 31 Aug 2014, at 17:41, David Celis notifications@github.com wrote:
Hey @Sija, check out #94 for more info on this. The tl;dr is that Redis doesn't keep track of when elements were added or removed from SETs, so it's not really possible unless I were to completely change which underlying data structures are used here (and I'm not terribly interested in doing that right now). Sorry!
— Reply to this email directly or view it on GitHub.
I don't do any sorting of the IDs, so those should indeed already be returned in insertion order. That's assuming that the order of elements returned by Redis is consistent. So something like liked_movie_ids
would, I'm guessing, be in insertion order but liked_movies
would not
@davidcelis yep, I count on that right now. thx for clarification :)
Just FYI, Recommendable uses redis#smembers
to get back array in liked_by_ids
method and Redis Sets are not sorted, therefore returned array will not keep the order of like insertions.
How about changing the underlying structure to Sorted sets which are providing such functionality? We could use timestamp as a score to keep 'em those likers in line :)
This has been requested before (I think in the issue I linked above), but I'm not really sold on changing the underlying data structure. It would be completely incompatible with everybody's current installation of recommendable, and I think that the added functionality is too niche since almost nobody asks for it. IMO this is something that should probably be implemented in the application itself; you can use the before/after hooks provided by recommendable to insert timestamp events in your primary datastore as you wish. Sorry that this answer is probably not what you were looking for!
Would be super handy for showing last
n
likes of given model.