Add synchronization to SP registry
This commit is contained in:
parent
091fd18c00
commit
f21ab8bfe6
|
@ -56,15 +56,17 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DaoConfig myDaoConfig;
|
private DaoConfig myDaoConfig;
|
||||||
|
|
||||||
private long myLastRefresh;
|
private volatile long myLastRefresh;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IFhirResourceDao<SearchParameter> mySpDao;
|
private IFhirResourceDao<SearchParameter> mySpDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forceRefresh() {
|
public void forceRefresh() {
|
||||||
|
synchronized (this) {
|
||||||
myLastRefresh = 0;
|
myLastRefresh = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Map<String, RuntimeSearchParam>> getActiveSearchParams() {
|
public Map<String, Map<String, RuntimeSearchParam>> getActiveSearchParams() {
|
||||||
|
@ -89,6 +91,8 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry {
|
||||||
|
|
||||||
private void refreshCacheIfNeccesary() {
|
private void refreshCacheIfNeccesary() {
|
||||||
long refreshInterval = 60 * DateUtils.MILLIS_PER_MINUTE;
|
long refreshInterval = 60 * DateUtils.MILLIS_PER_MINUTE;
|
||||||
|
if (System.currentTimeMillis() - refreshInterval > myLastRefresh) {
|
||||||
|
synchronized (this) {
|
||||||
if (System.currentTimeMillis() - refreshInterval > myLastRefresh) {
|
if (System.currentTimeMillis() - refreshInterval > myLastRefresh) {
|
||||||
StopWatch sw = new StopWatch();
|
StopWatch sw = new StopWatch();
|
||||||
|
|
||||||
|
@ -163,6 +167,8 @@ public class SearchParamRegistryDstu3 extends BaseSearchParamRegistry {
|
||||||
ourLog.info("Refreshed search parameter cache in {}ms", sw.getMillis());
|
ourLog.info("Refreshed search parameter cache in {}ms", sw.getMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private RuntimeSearchParam toRuntimeSp(SearchParameter theNextSp) {
|
private RuntimeSearchParam toRuntimeSp(SearchParameter theNextSp) {
|
||||||
String name = theNextSp.getCode();
|
String name = theNextSp.getCode();
|
||||||
|
|
Loading…
Reference in New Issue