Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4242652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:28:17+00:00 2026-05-21T03:28:17+00:00

I have a PHP website using a MySQL database. We have items that users

  • 0

I have a PHP website using a MySQL database.

We have items that users create, that are on a timer, and once this timer has counted down, without user interaction (basically next time someone sees it) the status needs to have changed.

I’m not sure how to implement this in a way to be accurate to the minute.

So we have an object X, that expires at 10:15pm tommorrow, and the next person to see object X after that time has to see it as expired.

Is the correct way to do this to be the next time object X is loaded we check if it’s expired, and if so, update the database?

What happens if 10 people load object X at the same time after it’s expired, what’s to prevent some sort of race condition from all 10 requests attempting to update the database?

Is there a cron job that runs every minute that I can some how make use of, or any type of timer in MySQL to kick off every minute checking for these and running a script?

I have several ideas on how it -could- be done, like those listed above, but I’m not sure what the most practical is, or what the standard way to do it is as I’m positive someone has solved this problem before.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:28:18+00:00Added an answer on May 21, 2026 at 3:28 am

    Is the correct way to do this to be the next time object X is loaded we check if it’s expired, and if so, update the database?

    Why do you need to update the database? It seems like you might have some redundancy in your DB table – from what you’ve said, it sounds like you have (for instance) an is_expired column and then an expires_at column.

    Why not just get rid of the is_expired column? It’s cheap to compare 2 integers, so when you want to determine if something is expired, just fetch the expires_at column and compare with the current time. This avoids any race conditions with expiry, since nothing in the DB changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webapp written in PHP using a MySQL database backend. This question
I have a PHP website backed by a MySQL database and a small team
I have a php classifieds website (mostly) and I am currently using MYSQL as
I am creating a website that is using a perl script, PHP, a MySQL
I have been using PHP and JavaScript for building my dad's website. He wants
I'm developing a website in PHP and I have large JS files that I
I have a website which uses PHP and HTML pages, I want to create
I'm fairly new to PHP and have built a medium sized website using standard
I've got a simple website using plain HTML/CSS to display and PHP/MySQL for data
I have a website that grabs a random entry from a database and displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.