pradeep cs
pradeep cs

Reputation: 523

ehcache search API - in case of joining two tables

i am trying to new cache configuration with new DB tables. following are sample table structure and sample Data.

TABLE_DEPT:

Dept Id      Detp Name     Dept Dtls
111          SALES         A1
112          MARKET        A2

TABLE_EMP:

Emp Id     Emp Name    DeptId    Working Started   Working ended
1          ABEmp       111       01-01-2017        02-02-2017
2          CDEmp       112       01-01-2017        03-12-2017
3          EFEmp       113       01-01-2017        03-12-2017
1          ABEmp       115       03-02-2017        03-12-2017

if i want to add load the data in cache by using Dept Id, i will have unique dept Id with list of emp Id - details.

if i want to search by dept id in ehcache configuration, i can simply give search attribute is "dept id". but, if i want to search by emp id, i should get list of dept under employee worked.

what should be my ehcache design?

my Java bean/POJO looks like below.

Class DeptDtls{

    int deptId;
    String deptName;
    List<Integer> empIdList;

    //Setter & getters
}

cache - i want to put key as deptId & value is whole DeptDtls.

in this case, how can i allow search operation based on empId?

Upvotes: 0

Views: 361

Answers (1)

user2622213
user2622213

Reputation: 1

Ehcache can provide in memory data storage only but in your case search also required on top cache.I got the same scenario and used elasticsearch for caching the data and search on stored data.elastic search has inbuilt support for search and we can index the stored data .elasticsearch can be configured for cache.

Upvotes: 0

Related Questions