Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Calendars and never ending recurring events.

  • Not really a Fuel thing, but I know there are some pretty smart people on here and I am looking for some advice.

    I am building a corporate calendar, (Have I ever mentioned how much I hate calendars and all dates?) and have almost all of it figured out.  But there is one piece that is really bugging me.  

    Never ending recurring events.

     

    Previously I would create 1 months of cached events every time something affected that month. I still kind of like that idea, because of things like never ending recurring events, but it was a lot of overhead sometimes for nothing.  So I made some changes on the way I am caching events, but this created a new hurdle.

     

    So the main idea is all events are cached into a cache table for each day that event occurs.  So a 1 day event has 1 cache entry for that date.  And event that spans over 5 days will have 5 entries (one for each day) in the cache table.  A recurring event that repeats 10 times will have 10 entries in the cache table.   I have indexes on Year, Month and Day that allows me to quickly retrieve all events for any time span.

     

    There are observers attached to my event model to automatically insert and update the cache when events are created or updated.

     

    There is a one-to-many relationship between events and cached_events that cascade the deletions from events to the cached_events.


    Al that works fine. 

     

    My last big hurdle is what to do with never ending events.  So far the only thing I can come up with is to specifically lookup up any never ending events with every query to get events, look at each one and see if it falls into the date span requested and if so add them to the output.  

    If I end up with a lot of never ending events this could take some overhead over time. Other idea is a separate table for these caches and flag what months have beed created and use that whenever possible and re-calculate that when a month has not yet beed created.  Of course I would have to go searching through all the never ending recurring events every time in needed to re-populate the cache. (Anytime a new never ending recurring event is added or modified)

     

    Just wondering if anyone might have some better ideas of how to cache never ending events.

    Thanks,
    Mike

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!