Package ca.uhn.fhir.jpa.cache
Class ResourceChangeListenerCacheRefresherImpl
java.lang.Object
ca.uhn.fhir.jpa.cache.ResourceChangeListenerCacheRefresherImpl
- All Implemented Interfaces:
IResourceChangeListenerCacheRefresher
,ca.uhn.fhir.jpa.model.sched.IHasScheduledJobs
@Service
public class ResourceChangeListenerCacheRefresherImpl
extends Object
implements IResourceChangeListenerCacheRefresher, ca.uhn.fhir.jpa.model.sched.IHasScheduledJobs
This service refreshes the
IResourceChangeListenerCache
caches and notifies their listener when
those caches change.
Think of it like a Ferris Wheel that completes a full rotation once every 10 seconds.
Every time a chair passes the bottom it checks to see if it's time to refresh that seat. If so,
the Ferris Wheel stops, removes the riders, and loads a fresh cache for that chair, and calls the listener
if any entries in the new cache are different from the last time that cache was loaded.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Refresh the cache in this entry and notify the entry's listener if the cache changedIf the current time is past the next refresh time of the registered listener, then check if any of its resources have changed and notify the listener accordinglyvoid
scheduleJobs
(ca.uhn.fhir.jpa.model.sched.ISchedulerService theSchedulerService) void
setResourceChangeListenerRegistry
(ResourceChangeListenerRegistryImpl theResourceChangeListenerRegistry) void
setResourceVersionSvc
(IResourceVersionSvc theResourceVersionSvc) void
shutdown()
void
start()
-
Constructor Details
-
ResourceChangeListenerCacheRefresherImpl
-
-
Method Details
-
scheduleJobs
- Specified by:
scheduleJobs
in interfaceca.uhn.fhir.jpa.model.sched.IHasScheduledJobs
-
refreshExpiredCachesAndNotifyListeners
Description copied from interface:IResourceChangeListenerCacheRefresher
If the current time is past the next refresh time of the registered listener, then check if any of its resources have changed and notify the listener accordingly- Specified by:
refreshExpiredCachesAndNotifyListeners
in interfaceIResourceChangeListenerCacheRefresher
- Returns:
- an aggregate of all changes sent to all listeners
-
forceRefreshAllCachesForUnitTest
-
setResourceChangeListenerRegistry
public void setResourceChangeListenerRegistry(ResourceChangeListenerRegistryImpl theResourceChangeListenerRegistry) -
setResourceVersionSvc
-
start
- Specified by:
start
in interfaceIResourceChangeListenerCacheRefresher
-
shutdown
- Specified by:
shutdown
in interfaceIResourceChangeListenerCacheRefresher
-
isStopping
-
refreshCacheAndNotifyListener
Description copied from interface:IResourceChangeListenerCacheRefresher
Refresh the cache in this entry and notify the entry's listener if the cache changed- Specified by:
refreshCacheAndNotifyListener
in interfaceIResourceChangeListenerCacheRefresher
- Parameters:
theCache
- theIResourceChangeListenerCache
with the cache and the listener- Returns:
- the number of resources that have been created, updated and deleted since the last time the cache was refreshed
-