J. Abraham
J. Abraham

Reputation: 97

Limiting redis queue within a range

I am working on redis queue (lists). Push is parallel and huge, whereas pop is single threaded. My queue is growing rapidly and I want to limit it within a range. I can handle it at the reader thread, where I pop and process.

Now, my question is, is there any way to limit the list without exceeding a certain limit? For example, say 100 without the need of popping one by one. I want to retain the new ones.

Upvotes: 1

Views: 292

Answers (1)

Karthikeyan Gopall
Karthikeyan Gopall

Reputation: 5689

Use Ltrim command in your reader thread.

http://redis.io/commands/LTRIM

Ltrim queue 0 100

Upvotes: 1

Related Questions