public Collection<K> getKeys() { return cache.getKeys(); }
@Nonnull @Override public Collection<K> getKeys() { return localCache.getKeys(); }
@Nonnull @Override public Collection<K> getKeys() { return localCache.getKeys(); }
private void clearCache() { if (log.isDebugEnabled()) { log.debug("Clearing issue security scheme cache, had " + schemeIdToSecuritiesCache.getKeys().size() + " scheme(s) and " + securityLevelToPermissionsCache.getKeys().size() + " security level(s)"); } schemeIdToSecuritiesCache.removeAll(); securityLevelToPermissionsCache.removeAll(); }
public Collection<DirectoryEntityKey> getKeys() { return getCache().getKeys(); }
protected <K, V> void assertSize(Cache<K, V> cache, final int expectedSize) { assertThat(cache.getKeys(), hasSize(expectedSize)); }
protected <K, V> void assertEmpty(Cache<K, V> cache) { assertThat(cache.getKeys(), Matchers.<K>empty()); }
public Set<String> getLoggedInUsers() { return new HashSet<>(getLoggedInUsersCache().getKeys()); }
@Override public String toString() { final StringBuilder sb = new StringBuilder(1024).append(getClass().getSimpleName()).append("[entries={"); final Collection<CacheKey> keys = entries.getKeys(); if (!keys.isEmpty()) { for (CacheKey key : keys) { sb.append("\n\t").append(key).append(" => ").append(entries.get(key)).append(','); } // Change the last comma to a newline sb.setCharAt(sb.length() - 1, '\n'); } return sb.append("}]").toString(); }
@ClusterSafe ( "We walk the keys of this map with the knowledge this is a canonical pinned cache of all existing tasks.") private Collection<? extends TaskDescriptorImpl<?>> getTasks(final Cache<Long, TaskDescriptorImpl<?>> taskMap) { List<TaskDescriptorImpl<?>> tasks = new ArrayList<TaskDescriptorImpl<?>>(); for (Long taskId : taskMap.getKeys()) { final TaskDescriptorImpl<?> taskDescriptor = taskMap.get(taskId); if (taskDescriptor != null) { tasks.add(taskDescriptor); } } return tasks; }
public void invalidateExpiredSessions() { Cache sessionCache = getSessionCache(); @SuppressWarnings("unchecked") Collection<String> uniqueSessionKeys = sessionCache.getKeys(); int sessionSize = uniqueSessionKeys.size(); logger.debug("Number of sessions before invalidation: " + sessionSize); if (sessionSize > 100) logger.warn("There are " + sessionSize + " active WebDAV sessions just before invalidation. Just thought of telling you that because there seems to be an unusual number of users using the WebDAV plugin."); for (String sessionKey : uniqueSessionKeys) { ConfluenceDavSession confluenceDavSession = getCachedSession(sessionCache, sessionKey); if (null != confluenceDavSession && isSessionExpired(confluenceDavSession)) sessionCache.remove(sessionKey); } logger.debug("Number of sessions after invalidation: " + sessionCache.getKeys().size()); }
@ClusterSafe ("the use of Cache.getKeys() is safe, as users and groups are fully populated, canonical caches") public List<T> getAll() { final Cache<DirectoryEntityKey,T> cache = getCache(); final Collection<DirectoryEntityKey> keys = cache.getKeys(); final List<T> values = new ArrayList<T>(keys.size()); for (DirectoryEntityKey key : keys) { final T value = cache.get(key); if (value != null) { values.add(value); } } return values; }
public void remove(BandanaContext context) { delegatedPersister.remove(context); // remove cached values associated with this context from this cache for (PersisterKey persisterKey : cache.getKeys()) { if (persisterKey.getContext().equals(context)) { cache.remove(persisterKey); } } }
@ClusterSafe ("the use of Cache.getKeys() is safe, as users and groups are fully populated, canonical caches") @GuardedBy("getLock()") private void buildCacheIfRequiredUnderLock(final Cache<DirectoryEntityKey,T> cache) { if (forceRefresh.get()) { buildCacheForced(cache); return; } final long expectedCount = countAllUsingDatabase(); final long actualCount = cache.getKeys().size(); // Note: Should be equal, but we'll guard against being unlucky enough to look right when a user gets added if (actualCount >= expectedCount) { LOG.debug("Cache size matched entity count (once under lock); skipping cache rebuild for " + entityName); } else { LOG.debug("Cache size (" + actualCount + ") < " + entityName + " database size; refreshing..."); visitAllUsingDatabase(new PutIfAbsentVisitor(cache)); } }
@ClusterSafe ("This use of Cache.getKeys() here is just a sort of optimisation and is safe.") @Override public CacheObject<Avatar> load(@Nullable Long id) { if (taggedAvatars.getKeys().contains(id)) { return taggedAvatars.get(id); } else { final GenericValue gv = ofBizDelegator.findById(AVATAR_ENTITY, id); if (gv == null) { return new CacheObject<>(null); } return new CacheObject<>(gvToAvatar(gv)); } } }
public void executeTaskOnSessions(ConfluenceDavSessionTask confluenceDavSessionTask) { Cache sessionCache = getSessionCache(); @SuppressWarnings("unchecked") Collection<String> uniqueSessionKeys = sessionCache.getKeys(); for (String sessionKey : uniqueSessionKeys) { ConfluenceDavSession confluenceDavSession = (ConfluenceDavSession) sessionCache.get(sessionKey); confluenceDavSessionTask.execute(confluenceDavSession); /* Update the cache with possibly modified session */ mapSession(confluenceDavSession, confluenceDavSession.getUserName()); } } }
@ClusterSafe ("the use of Cache.getKeys() is safe, as users and groups are fully populated, canonical caches") public void visitAllInDirectory(final long directoryId, Visitor<T> visitor) { final Cache<DirectoryEntityKey,T> cache = getCache(); for (DirectoryEntityKey key : cache.getKeys()) { if (key.getDirectoryId() == directoryId) { final T value = cache.get(key); if (value != null) { visitor.visit(value); } } } }