[英]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: TABLE_DEPT:
Dept Id Detp Name Dept Dtls
111 SALES A1
112 MARKET A2
TABLE_EMP: 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. 如果我想使用部门ID添加加载缓存中的数据,我将拥有唯一的部门ID和emp ID列表-详细信息。
if i want to search by dept id in ehcache configuration, i can simply give search attribute is "dept id". 如果我想按ehcache配置中的部门ID搜索,我可以简单地将搜索属性设为“部门ID”。 but, if i want to search by emp id, i should get list of dept under employee worked. 但是, 如果我想按emp id进行搜索,我应该在工作过的员工下得到部门的清单。
what should be my ehcache design? 我的ehcache设计应该是什么?
my Java bean/POJO looks like below. 我的Java bean / POJO如下所示。
Class DeptDtls{
int deptId;
String deptName;
List<Integer> empIdList;
//Setter & getters
}
cache - i want to put key as deptId & value is whole DeptDtls. 缓存-我想将键设置为deptId和值是整个DeptDtls。
in this case, how can i allow search operation based on empId? 在这种情况下,如何允许基于empId的搜索操作?
Ehcache只能提供内存数据存储,但是在您的情况下,顶级缓存也需要搜索。我遇到了相同的情况,并使用elasticsearch缓存数据并搜索存储的数据.elastic search内置了对搜索的支持,我们可以为存储的索引可以将data .elasticsearch配置为用于缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.