public Map<String, Object> getRequestCache() { return JiraAuthenticationContextImpl.getRequestCache(); }
private Boolean getEnabledCachedWrapperFlag() { final Boolean flag = (Boolean) JiraAuthenticationContextImpl.getRequestCache().get(RequestCacheKeys.WRAP_PERMISSION_FILTER_IN_CACHED_WRAPPER_CACHE); return (flag == null) ? Boolean.FALSE : flag; } }
@VisibleForTesting Map<String, Object> getRequestCache() { return JiraAuthenticationContextImpl.getRequestCache(); }
private void flushCustomFieldValueCache() { // TODO This is a horrible hack to stop the field values cache growing out of control during a reindex. Find a better way! final Map<?, ?> customFieldValueCache = (Map<?, ?>) JiraAuthenticationContextImpl.getRequestCache().get(RequestCacheKeys.CUSTOMFIELD_VALUES_CACHE); if (customFieldValueCache != null) { customFieldValueCache.clear(); } // TODO:end }
static <K, V> Map<K, V> getCache(final String key) { final Map<String, Object> requestCache = JiraAuthenticationContextImpl.getRequestCache(); @SuppressWarnings("unchecked") Map<K, V> result = (Map<K, V>) requestCache.get(key); if (result == null) { result = new HashMap<K, V>(); requestCache.put(key, result); } return result; }
@Override public boolean shouldSectionBeLazy(final String section) { final LoadingCache<String, Boolean> cache = getRequestCache(LAZY_SECTION_KEY, () -> CacheBuilder.newBuilder().build(new CacheLoader<String, Boolean>() { @Override public Boolean load(@Nonnull final String key) throws Exception { return ThreadLocalCachingSimpleLinkManager.super.shouldSectionBeLazy(key); } })); return cache.getUnchecked(section); }
private SQLPerfCache getCache() { final SQLPerfCache sqlPerfCache = (SQLPerfCache) JiraAuthenticationContextImpl.getRequestCache().get(SQL_PERF_CACHE); if (sqlPerfCache == null) { final SQLPerfCache perfCache = new SQLPerfCache(); JiraAuthenticationContextImpl.getRequestCache().put(SQL_PERF_CACHE, perfCache); return perfCache; } return sqlPerfCache; }
public CachingUserFormat(final UserFormat delegate) { this.delegate = delegate; final Map<String, Object> requestCache = JiraAuthenticationContextImpl.getRequestCache(); @SuppressWarnings("unchecked") Cache<Key, Option<String>> cache = (Cache<Key, Option<String>>) requestCache.get(RequestCacheKeys.USER_FORMAT_CACHE); if (cache == null) { cache = CacheBuilder.newBuilder().maximumSize(MAX_CACHE_SIZE).build(); requestCache.put(RequestCacheKeys.USER_FORMAT_CACHE, cache); } this.cache = cache; }
/** * A cache to store the custom field values in. Remember this guy is threadlocal so no need to synchronise */ private Map<CacheKey, SoftReference<List<?>>> getCache() { @SuppressWarnings("unchecked") @ClusterSafe Map<CacheKey, SoftReference<List<?>>> cache = (Map<CacheKey, SoftReference<List<?>>>) JiraAuthenticationContextImpl.getRequestCache().get( RequestCacheKeys.CUSTOMFIELD_VALUES_CACHE); if (cache == null) { cache = new ConcurrentHashMap<>(); JiraAuthenticationContextImpl.getRequestCache().put(RequestCacheKeys.CUSTOMFIELD_VALUES_CACHE, cache); } return cache; }
private CachedWrappedFilterCache getCachedWrappedFilterCache() { CachedWrappedFilterCache cache = (CachedWrappedFilterCache) JiraAuthenticationContextImpl.getRequestCache().get( RequestCacheKeys.CACHED_WRAPPED_FILTER_CACHE); if (cache == null) { if (log.isDebugEnabled()) { log.debug("Creating new CachedWrappedFilterCache"); } cache = new CachedWrappedFilterCache(); JiraAuthenticationContextImpl.getRequestCache().put(RequestCacheKeys.CACHED_WRAPPED_FILTER_CACHE, cache); } return cache; }
PermissionsFilterCache getCache() { PermissionsFilterCache cache = (PermissionsFilterCache) JiraAuthenticationContextImpl.getRequestCache().get( RequestCacheKeys.PERMISSIONS_FILTER_CACHE); if (cache == null) { if (log.isDebugEnabled()) { log.debug("Creating new PermissionsFilterCache"); } cache = new PermissionsFilterCache(); JiraAuthenticationContextImpl.getRequestCache().put(RequestCacheKeys.PERMISSIONS_FILTER_CACHE, cache); } return cache; } ///CLOVER:ON
private PermissionsCache getCache() { PermissionsCache cache = (PermissionsCache) JiraAuthenticationContextImpl.getRequestCache().get(RequestCacheKeys.PERMISSIONS_CACHE); if (cache == null) { if (log.isDebugEnabled()) { log.debug("Creating new PermissionsCache"); } cache = new PermissionsCache(projectFactory); JiraAuthenticationContextImpl.getRequestCache().put(RequestCacheKeys.PERMISSIONS_CACHE, cache); } return cache; } }
@Override @Nonnull public List<SimpleLink> getLinksForSectionIgnoreConditions(@Nonnull final String section, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper) { final LoadingCache<CacheKey, List<SimpleLink>> cache = getRequestCache(LINKS_FOR_SECTION_IC_KEY, () -> CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<SimpleLink>>() { @Override public List<SimpleLink> load(@Nonnull final CacheKey key) throws Exception { return ThreadLocalCachingSimpleLinkManager.super.getLinksForSectionIgnoreConditions(key.location, key.remoteUser, key.jiraHelper); } })); return cache.getUnchecked(new CacheKey(section, remoteUser, jiraHelper)); }
@Override @Nonnull public List<SimpleLinkSection> getSectionsForLocation(@Nonnull final String location, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper) { final LoadingCache<CacheKey, List<SimpleLinkSection>> cache = getRequestCache(SECTIONS_FOR_LOCATION_KEY, () -> CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<SimpleLinkSection>>() { @Override public List<SimpleLinkSection> load(@Nonnull final CacheKey key) throws Exception { return ThreadLocalCachingSimpleLinkManager.super.getSectionsForLocation(key.location, key.remoteUser, key.jiraHelper); } })); return cache.getUnchecked(new CacheKey(location, remoteUser, jiraHelper)); }
@Override public boolean shouldLocationBeLazy(@Nonnull final String location, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper) { final LoadingCache<CacheKey, Boolean> cache = getRequestCache(LAZY_LOCATION_KEY, () -> CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, Boolean>() { @Override public Boolean load(@Nonnull final CacheKey key) throws Exception { return ThreadLocalCachingSimpleLinkManager.super.shouldLocationBeLazy(key.location, key.remoteUser, key.jiraHelper); } })); return cache.getUnchecked(new CacheKey(location, remoteUser, jiraHelper)); }
@Override @Nonnull public List<SimpleLink> getLinksForSection(@Nonnull final String section, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper, final boolean addIconCachingPrefix) { final LoadingCache<CacheKey, List<SimpleLink>> cache = getRequestCache(LINKS_FOR_SECTION_KEY, () -> CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<SimpleLink>>() { @Override public List<SimpleLink> load(@Nonnull final CacheKey key) throws Exception { return ThreadLocalCachingSimpleLinkManager.super.getLinksForSection(key.location, key.remoteUser, key.jiraHelper, key.addIconPrefix); } })); return cache.getUnchecked(new CacheKey(section, remoteUser, jiraHelper, addIconCachingPrefix)); }
private void countAndLogSearchesInDevMode() { if (JiraSystemProperties.getInstance().isDevMode()) { final Integer devSearchCounter = (Integer) JiraAuthenticationContextImpl.getRequestCache().get("devmode.filter.usage.count"); final Integer devNewSearchCounter = (devSearchCounter == null) ? 1 : devSearchCounter + 1; JiraAuthenticationContextImpl.getRequestCache().put("devmode.filter.usage.count", devNewSearchCounter); if (devSearchCounter != null && devSearchCounter >=2 && !getEnabledCachedWrapperFlag()) { log.warn("This request asked for permission filter " + devNewSearchCounter + " times already " + "and RequestCacheKeys.WRAP_PERMISSION_FILTER_IN_CACHED_WRAPPER_CACHE flag is set to 'false' while it should be set to 'true'"); } } }
@Nonnull protected LoadingCache<ImmutableMap<String, Object>, String> getRequestCache() { return JiraAuthenticationContextImpl.getRequestCache(CACHE_KEY, () -> CacheBuilder.newBuilder().build(CacheLoader.from(params -> { Map<String, Object> velocityParams = Maps.newHashMap(params); velocityParams.put("soyRenderer", soyTemplateRendererProvider.getRenderer()); return renderTemplate("status-columnview.vm", velocityParams); }))); }
protected LoadingCache<Long, ImmutableSet<String>> getWatchersCache() { final LoadingCache<Long, ImmutableSet<String>> cache = newBuilder().build(from(issueId -> ImmutableSet.copyOf(userAssociationStore.getUserkeysFromIssue(ASSOCIATION_TYPE, issueId)))); if (ExecutingHttpRequest.get() != null) { return getRequestCache(CACHE_KEY, () -> cache); } else { return cache; } } }
@Nonnull protected LoadingCache<Long, ImmutableSet<String>> getVotersCache() { final LoadingCache<Long, ImmutableSet<String>> cache = newBuilder().build(from(issueId -> ImmutableSet.copyOf(userAssociationStore.getUserkeysFromIssue(ASSOCIATION_TYPE, issueId)))); if (ExecutingHttpRequest.get() != null) { return getRequestCache(CACHE_KEY, () -> cache); } else { return cache; } } }