

If you know your data is pretty stable, i.e. Now, if in addition you throw a cache into that mix, it's a third data store to maintain and to ensure is consistent with the main data store. as soon as you start duplicating data (DB -> ES), you need to ensure that both stores don't get out of synch. usually faster than retrieving the same data from your DB, it would make sense to use ES as a cache. You also need to ask yourself whether your cache needs to be distributed across several hosts or not (whether now or in the future).Ĭonsidering that lookups and queries in ES are extremely fast (+ ES brings you many more benefits in addition to that, such as scoring), i.e.

That being said, it comes as no surprise that if you plan to have a few million/billion records in your DB, it won't be difficult to index them all but it will be difficult to cache them all, though since RAM is getting cheaper and cheaper, you might be able to store all you need in memory. One constraint of caches is that they cannot be too big either as the lookup time would increase and thus defeat the purpose of having a cache in the first place. The whole purpose of a cache is to return already requested data as fast as possible. I think I have a better idea now though especially when I realized that not all fields are always stored in the index and so therefore we need to get the object from a cache or direct from the db anyway - at least in some cases. After all, I wouldn't want to keep 2 caches in memory (example: ElasticSearch + Redis) when one would do fine. I am fully aware of what a cache is and already understood the general idea behind an index for textual searching, so I was only really wondering whether the index doubles as a cache already and would therefore make any other cache redundant.

Would this become redundant with ElasticSearch? something like this: return CacheManager.Get(cacheKey, () => Would there ever be any real reason to use both a caching solution and indexing solution within the same project or does the indexing solution basically make any other caching redundant?Įxample: Say I use NEST for ElasticSearch, which would store and return POCOs if I then query ElasticSearch and have the POCO returned to me, isn't that considered to be using a cached object returned from ElasticSearch?Īt the moment, I store data in a cache using an ICacheManager interface I have. What's the real difference between a caching solution and an indexing solution? It seems to me that an indexing solution is in fact caching with the ability to run search queries (like: Elastic Search).
