title: Shared redis instance by multiple instances of same application
body: <p>We have been asked to implement caching in an application using redis. The application should have a logic to <strong>clear cache</strong> on startup and initialize it.
  However, <strong>the redis instance can be shared by multiple instances of the application.</strong></p>
  
  <p>e.g. application <strong>X</strong> has two instances <strong>X0</strong> and <strong>X1</strong> sharing the same redis instance.</p>
  
  <p><strong>Problem:</strong>
   With multiple instances, it is possible that one instance trying to initialize the cache while other instance is clearing it.</p>
  
  <p><strong>Two questions</strong></p>
  
  <p>1) How do make sure while cache is getting initialized, other instance does not clear it.</p>
  
  <p><strong>One way to solve this problem is to maintain a flag in redis to check if it is being cleared or initialized. If cache is being initialized, do not clear or re-initlize it.</strong></p>
  
  <p>2) Is it good practice to have shared redis instance by multiple application instances?</p>