2

My use case is as following:

Application clients uses Distributed Cache (Memcached/Redis/etc) to cache the DB output. I would want to add one more functionaloty hidden from Application Clients - How to Handle Cache Miss e.g. Application client just asks to get values for key to Distributed Cache (without knowing the DB details). Now, it would want the distributed cache to handle the cache-miss - get the data from Relational DB and cache it.

It seems Redis/Memcached do not provide such feature. Am I missing something or I should be looking at some other tool/framework for this use case.

Sandeep Jindal
  • 14,510
  • 18
  • 83
  • 121
  • I don't think redis has connector to mysql directly, so it doesn't know what data it is caching, I think you would have to handle it in app layer or write a proxy service in front of redis – jmj Jan 26 '15 at 03:43

1 Answers1

2

You need to use read-through/write-through caching pattern where client application will consider cache as main data store and perform all read and write operations on cache. Cache on other hand will be responsible to sync itself with the database using deployed read-through/write-through providers.

On read operation if data is not present in cache, cache will itself load data from database avoiding cache miss.

Read this article by Iqbal Khan for further details on read-through/write-behind caching.

This feature is available in TayzGrid by Alachisoft. Java client of NCache also provides this feature.

Sameer Shah
  • 1,073
  • 7
  • 12