0

I'm developing a web application for medical purposes, where the users can create an appointment for a specific patient, doctor and facility. Each facility may have N doctors, and the calendar will be populated with N appointments per doctor and will also show the availabilites of each doctor (ex.: Doctor Who works on wednesday from 9:00 to 12:00 and from 15:00 to 18:00).

For the front-end part I'm using fullcalendar and the backend is made using Struts2 (controllers) + Spring (dependency injection) + Hibernate (DAO).

Since a user (usually) has to load the appointments from this week to a month or two in the future, and there may be from one to N users for each facility that will use this view for a long time, I'd like to cache the appointments + availabilities using Redis and I've added to my project the Spring data redis with Lettuce client. The idea is to use the @Cacheable, @CachePut and @CacheEvict annotations for the DAO's methods, handling the users action like list, create and update the appointments avoiding conflicts between the redis data and the database data and other concurrency problems.

My questions are:

  1. Is this the correct strategy?
  2. Should I implement a custom key generator in order to cache the appointments besed on the facility + doctor ids?
IlGala
  • 3,331
  • 4
  • 35
  • 49
  • 1
    The pattern fits to the Spring Cache programming model. Before you start caching, you should run performance tests to figure out whether Caching is a solution or a symptom. You should make sure that your objects are serializable - you don't want to cache JPA proxies but the data inside the data model. Regarding key generators: It depends. Specify a SpEL expression to create non-conflicting keys and see whether that fits. – mp911de Sep 08 '16 at 20:10

1 Answers1

0

What I understood from here that you have separate data from appointments and availabilities which you want to cache in redis so that unnecessary db call can be avoided and improve the performance.

I have few points here:

  1. If you have less data, then it will not improve performance as I assume redis server will be remotely placed and it has network overhead also. So you can choose any InMemory Cache as Guava cache.

  2. If there are heavy data uses then you redis is beneficial. Now i come to first point that if this is correct strategy? I will say yes. For second point, if you need to implement custom key generator or not depends upon the way you store the data in redis uniquely. Redis is (key,value) store. So I think appointments will be uniquely identified from(facility + doctor ids) you need to implement CustomKeyGenerator.

rudimeier
  • 854
  • 1
  • 8
  • 20
Umesh
  • 21
  • 2