comp500
comp500

Reputation: 364

Expiring MySQL entries

I want to make a table where the entries expire 24 hours after they have been inserted in PHP and MySQLi/MySQL on a Linux server. I am using it for my program which will upload data to the server for transferring to another computer - but to save on storage and reduce server load I want to make so that the data will expire after 24 hours. It works like this:

  1. The user tells my program to get a transfer code.
  2. My program uploads its data to the server and the server returns with an Unique ID - my program then displays it to the user.
  3. The user types it in on a different computer with my program on it.
  4. My program downloads the data from the server, which then deletes the entry from the database.
  5. If the user does not type the code in within 24 hours, somehow the server will delete it.

I could use a cron job to run a php file every hour but that could increase server load especially because my server is going to be used for lots of other things and there is probably a better way in MySQLi.

Also, the programming language I am using is not that capable of doing it client-side and SSL is not available on on my server.

Upvotes: 0

Views: 143

Answers (1)

slash197
slash197

Reputation: 9034

Use a cron job which runs once a day and deletes all entries that are older than 24 hours.

Upvotes: 2

Related Questions