Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Stelikas's avatar

Restrict access to a page when event fires

Hello, i have created a booking system which synchronizes with Google Calendar every 5 minutes and also truncates and old data and fetches new one from calendar, this process takes about 2-3 seconds.

What i want to do is, when the event to fetch data from Google Calendar fires, i want to disable access to the booking system for these 2-3 seconds then enable it again when the event ends, i want to do this because it truncates the old data and fetches new one, so if a person is looking at the booking system this 2-3 seconds all the book schedule times will be free and i don't want this to happen.

Is this kind of thing possible? Thanks and regards!

0 likes
4 replies
tykus's avatar
tykus
Best Answer
Level 104

In the job that fetches the Google Calendar data, you probably could set a lock in your cache, or database, which is checked before the booking system controller action returns a view/accepts form data. You can then remove the lock whenever the job completes.

Stelikas's avatar

Any good documentation on how to do that?

martinbean's avatar

@stelikas This is an awful approach.

Calendar entries in Google Calendar will almost certainly have some form of unique identifier that you can use to update existing entries, instead of trashing all of your data and re-inserting it fresh every five minutes.

Your application is just going to look glitchy if every five minutes it “freezes” and no one can do anything with it for a few seconds. And that time is just going to grow the more and more entries you need to deal with.

Stelikas's avatar

I agree, i'm not the one who developed the Booking System, it came to me like that and i'm trying to find solutions to make it work more efficient.

Please or to participate in this conversation.