0

I have some data in the database I want to read into 2 cache:
1. Entire json representing row of data
2. Just a subset of columns for quick querying purposes

I have a MapStore for persistence to the first cache with the json. I am thinking of using an EntryListener on the main json cache so when we add a value there, the entry listener will then write to the other cache. Does this approach sound like a good way to do it?

Pilo
  • 15
  • 3

2 Answers2

0

Yes, it sounds ok. Just note that it is better to off-load the logic in the EntryListener to another thread, not to block eventing threads in Hazelcast when you perform long-running operations in listeners.

You can also think usage of interceptors: https://docs.hazelcast.org//docs/latest/manual/html-single/index.html#adding-interceptors Again, you need to off-load the logic also for interceptors as I mentioned above.

Alparslan Avci
  • 931
  • 4
  • 6
0

As I understand you have the second map just for querying purposes. You can use Indexes or even a Continuous Query Cache on the first map and not have a second map at all.

sertug
  • 872
  • 6
  • 10
  • A continuous query cache filters rows only but not columns right? – Pilo Nov 14 '18 at 15:30
  • That's correct, in that case that wouldn't help, but if you want to return only a subset of fields you can use Projections in combination of Predicates as well. Please remember to index the fields you want to query. https://docs.hazelcast.org//docs/3.11/manual/html-single/index.html#projections – sertug Nov 16 '18 at 11:53