xierui
xierui

Reputation: 1055

how to get latest 10 visitor for each item

I have a web application now. I just to want to get latest 10 visitor who have seen some specify item. But I do not want to save all the visit info to mysql. Is there any better way to implement the feature?

As I am using redis, dose redis have some feature to support such situation?

Upvotes: 1

Views: 51

Answers (1)

Itamar Haber
Itamar Haber

Reputation: 50052

You can store the the latest viewers per item as a List in Redis, and keep each List to exactly 10 visitors by using LTRIM on it.

Upvotes: 2

Related Questions