views:

27

answers:

1

I've created a model called Request, which is created when one user makes a request with another user. I'd like each request to only exist for 5 minutes. Is this possible?

+3  A: 

Couple of ways to do this ... you could add a Sweeper or delayed job to clear the values from the database periodically. Give each record a created_at, clear after 5 minutes.

Alternative would be to do this check when presenting the information to the user ... similar idea, have a created_at, when you check the pending requests for the current user you ignore or delete any that are older than 5 minutes.

Toby Hede
Checking and deleting the requests when presenting them to the user sounds good. Thanks for your help!
ben