Package com.atlassian.jira.user
Class CachingUserHistoryStore
java.lang.Object
com.atlassian.jira.user.CachingUserHistoryStore
- All Implemented Interfaces:
InitializingComponent,UserHistoryStore
public class CachingUserHistoryStore
extends Object
implements UserHistoryStore, InitializingComponent
Caching implementation of
UserHistoryStore.
This is very broken, but no more broken than any of the other caches.- Since:
- v4.0
-
Constructor Summary
ConstructorsConstructorDescriptionCachingUserHistoryStore(OfBizUserHistoryStore delegatingStore, ApplicationProperties applicationProperties, com.atlassian.cache.CacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHistoryItem(ApplicationUser user, UserHistoryItem historyItem) Add a history item to the database.voidCalled after all the beans are constructed and the ApplicationContext is fully populated.getHistory(UserHistoryItem.Type type, ApplicationUser user) Retrieve the history for a given user/type.getHistory(UserHistoryItem.Type type, String userKey) Retrieve the history for a given user/type.static intgetMaxItems(UserHistoryItem.Type type, ApplicationProperties applicationProperties) voidonClearCache(ClearCacheEvent event) voidonComponentManagerShutdown(ComponentManagerShutdownEvent shutdownEvent) voidonComponentManagerStarted(ComponentManagerStartedEvent startedEvent) Schedules the cache cleanup task.voidRemove all history items for a given user.voidremoveHistoryOlderThan(Long timestamp) Method for removing old user history items.
-
Constructor Details
-
CachingUserHistoryStore
public CachingUserHistoryStore(@Nonnull OfBizUserHistoryStore delegatingStore, @Nonnull ApplicationProperties applicationProperties, @Nonnull com.atlassian.cache.CacheManager cacheManager)
-
-
Method Details
-
afterInstantiation
Description copied from interface:InitializingComponentCalled after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.- Specified by:
afterInstantiationin interfaceInitializingComponent- Throws:
Exception
-
onComponentManagerStarted
Schedules the cache cleanup task. -
onComponentManagerShutdown
-
onClearCache
-
onUserHistoryItemFKChangedEvent
-
addHistoryItem
Description copied from interface:UserHistoryStoreAdd a history item to the database. This removes the currently referred to entity (user, type, id) from the list and then adds it. If adding it causes the history items stored for that user/type to exceed the max (jira.max.history.items) items allowed, it should remove the oldest items.- Specified by:
addHistoryItemin interfaceUserHistoryStore- Parameters:
user- The user to store the history item againsthistoryItem- the item to store. Containing a timestamp and referenced entity
-
getHistory
@Nonnull public List<UserHistoryItem> getHistory(@Nonnull UserHistoryItem.Type type, @Nonnull String userKey) Description copied from interface:UserHistoryStoreRetrieve the history for a given user/type.- Specified by:
getHistoryin interfaceUserHistoryStore- Parameters:
type- The type of entity to retrieve history for.userKey- The key of the user to retrieve history for.- Returns:
- a list containing all stored history items for the passed in user/type.
-
getHistory
@Nonnull public List<UserHistoryItem> getHistory(@Nonnull UserHistoryItem.Type type, @Nonnull ApplicationUser user) Description copied from interface:UserHistoryStoreRetrieve the history for a given user/type.- Specified by:
getHistoryin interfaceUserHistoryStore- Parameters:
type- The type of entity to retrieve history for.user- The user to retrieve history for.- Returns:
- a list containing all stored history items for the passed in user/type.
-
removeHistoryForUser
Description copied from interface:UserHistoryStoreRemove all history items for a given user.- Specified by:
removeHistoryForUserin interfaceUserHistoryStore- Parameters:
user- The user to remove all history of.- Returns:
- The set of history types that were removed;
-
removeHistoryOlderThan
Description copied from interface:UserHistoryStoreMethod for removing old user history items. Removes elements older than provided timestamp, but not younger than 30 days.- Specified by:
removeHistoryOlderThanin interfaceUserHistoryStore- Parameters:
timestamp- remove elements older than this timestamp
-
getMaxItems
public static int getMaxItems(UserHistoryItem.Type type, ApplicationProperties applicationProperties)
-