views:

24

answers:

0

Hi all..

I need to model a calendar, and I got some ideas myself, but I would like some input from you guys :)

The domain is as follows: A calendar contains time entries (think google calendar here). For each group and day in the calendar, I have a starttime and an endtime, denoting the time its possible to enter new appointments in between. An appointment has a starttime and an endtime as well.
When someone uses the calendar (s)he will see a number of available time slots, each with a duration of 15 minutes.

Now, I came up with 3 ideas:

Use the start- and endtime of the appointments
This way, every time I need to render the calendars time slots, I have to calculate them based on the start- and end time of the appointments, which scales poorly concerning CPU time.

Disregard the appointments and only use the time slots
This way, whenever a new appointment is made, the time slots will be updated, and thus only calculates the time slots when theres a CRUD operation on an appointment. This way, I'll get nice CPU scalability, however, persisting all the time slots will take up a lot of space.

Keep a cache in memory of the time slots and only persist the appointments
This way, I get the best of both worlds - Good CPU scalability, and nice persistence scalability. The problem is, that it's a (fair) assumption that whenever the time slots are calculated, it's very likely that a new appointment will be made, thus invalidating the cache. I need to run some tests on this approach to find out if it's feasible.

--

Before I get into too much work of doing simulations and the likes, I would like to know if anyone has other ideas about how this could be done more scalable (concerning CPU and persistence).
If you feel you need to know more about the domain before thinking about this, feel free to post a comment and I'll update the question ASAP :)

Hoping someone has some magic for me ;)
- cwap