Interface CacheContext
- All Known Implementing Classes:
CurrentCacheContext
public interface CacheContext
-
Method Summary
Modifier and Type Method Description voiddesync()Set the context as DESYNCHRONIZEDvoiderror(CachedException exception)Store the exception for its occurrence timevoiderrorUpdateDate(CachedException updatedException)Store the last occurrence of this exceptionCacheStateEnumgetCurrentState()Returns the current state in the cacheCachedExceptiongetException()Returns the met exceptionDategetLastStateTransitionTime()Returns the date of the last state transitionDategetLastSuccessSynchronizationTime()Returns the last time when the cache has been synchronized successfully NOTE: can be null in case if the cache has never been synchronizedbooleanisDesync()Returns TRUE if the cache is in DESYNC statusbooleanisError()Returns TRUE if the cache is in a error statusbooleanisRefreshNeeded()Returns TRUE is a refresh is needed (missing / expired data)booleanisToBeDeleted()Returns TRUE if the cache is in TO_BE_DELETED statusvoidrefreshNeeded()Set the context as REFRESH_NEEDEDvoidstate(CacheState newState)This method operates a state changevoidsync()Set the context as SYNCHRONIZEDvoidsyncUpdateDate()Updates the lastSuccessSynchronization datevoidtoBeDeleted()Set the context as TO_BE_DELETED
-
Method Details
-
getCurrentState
CacheStateEnum getCurrentState()Returns the current state in the cache- Returns:
- the Cache state
-
getLastStateTransitionTime
Date getLastStateTransitionTime()Returns the date of the last state transition- Returns:
- the last date when the state has had a transition
-
getLastSuccessSynchronizationTime
Date getLastSuccessSynchronizationTime()Returns the last time when the cache has been synchronized successfully NOTE: can be null in case if the cache has never been synchronized- Returns:
- the last date when the state has been synchronized
-
state
This method operates a state change- Parameters:
newState- the new state to be assigned
-
desync
void desync()Set the context as DESYNCHRONIZED -
sync
void sync()Set the context as SYNCHRONIZED -
refreshNeeded
void refreshNeeded()Set the context as REFRESH_NEEDED -
toBeDeleted
void toBeDeleted()Set the context as TO_BE_DELETED -
isRefreshNeeded
boolean isRefreshNeeded()Returns TRUE is a refresh is needed (missing / expired data)- Returns:
- TRUE if a refresh is required
-
syncUpdateDate
void syncUpdateDate()Updates the lastSuccessSynchronization date -
isError
boolean isError()Returns TRUE if the cache is in a error status- Returns:
- TRUE if an exception is stored
-
error
Store the exception for its occurrence time- Parameters:
exception- an instance ofCachedException
-
errorUpdateDate
Store the last occurrence of this exception- Parameters:
updatedException- an instance ofCachedException
-
getException
CachedException getException()Returns the met exception- Returns:
- an object with the exception and its occurrence time
-
isToBeDeleted
boolean isToBeDeleted()Returns TRUE if the cache is in TO_BE_DELETED status- Returns:
- TRUE if the entry must be deleted
-
isDesync
boolean isDesync()Returns TRUE if the cache is in DESYNC status- Returns:
- TRUE if the entry is desynchronized
-