/** * Checks if the cache is empty or if at last one element is contained.<p> * * @return true if the cache is empty, false otherwise */ boolean isEmpty() { if (!isEnabled()) { return true; } return m_keyCache.isEmpty(); }
/** * Returns the total number of cached resource keys. * * @return the number of resource keys in the cache */ public int keySize() { if (!isEnabled()) { return 0; } return m_keyCache.size(); }
/** * Checks if the cache is empty or if at last one element is contained.<p> * * @return true if the cache is empty, false otherwise */ boolean isEmpty() { if (!isEnabled()) { return true; } return m_keyCache.isEmpty(); }
/** * Returns the total number of cached resource keys. * * @return the number of resource keys in the cache */ public int keySize() { if (!isEnabled()) { return 0; } return m_keyCache.size(); }
/** * Returns a set of all cached resource names.<p> * * Useful if you want to show a list of all cached resources, * like on the FlexCache administration page.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> * * @param cms the CmsObject used for user authorization * @return a Set of cached resource names (which are of type String) */ public Set<String> getCachedResources(CmsObject cms) { if (!isEnabled() || !OpenCms.getRoleManager().hasRole(cms, CmsRole.WORKPLACE_MANAGER)) { return null; } return m_keyCache.keySet(); }
/** * Returns a set of all cached resource names. * Usefull if you want to show a list of all cached resources, * like on the FlexCache administration page.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> * * @param cms the CmsObject used for user authorization * @return a Set of cached resource names (which are of type String) */ public Set getCachedResources(CmsObject cms) { if (!isEnabled() || !OpenCms.getRoleManager().hasRole(cms, CmsRole.WORKPLACE_MANAGER)) { return null; } return m_keyCache.keySet(); }
/** * Empties the cache completely.<p> */ private synchronized void clear() { if (!isEnabled()) { return; } m_keyCache.clear(); m_size = 0; m_variationCache.clear(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_0)); } }
/** * Emptys the cache completely.<p> */ private synchronized void clear() { if (!isEnabled()) { return; } m_keyCache.clear(); m_size = 0; m_variationCache.clear(); if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_0)); } }
/** * Clears all entries from offline projects in the cache.<p> * * The keys from the offline projects are not cleared. * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOfflineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_OFFLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, true); }
/** * Clears all entries from the online project in the cache.<p> * * The keys from the online project are not cleared. * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnlineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, true); }
/** * Removes an entry from the cache.<p> * * @param key the key which describes the entry to remove from the cache */ void remove(CmsFlexCacheKey key) { if (!isEnabled()) { return; } CmsFlexCacheVariation o = m_keyCache.get(key.getResource()); if (o != null) { I_CmsLruCacheObject old = o.m_map.get(key.getVariation()); if (old != null) { getEntryLruCache().remove(old); } } }
/** * Clears all entries and all keys from the online project in the cache.<p> * * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, false); }
/** * Clears all entries and all keys from offline projects in the cache.<p> * * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOffline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, false); }
/** * Clears all entries and all keys from the online project in the cache.<p> * * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, false); }
/** * Clears all entries and all keys from offline projects in the cache.<p> * * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOffline() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_KEYS_AND_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, false); }
/** * Removes an entry from the cache.<p> * * @param key the key which describes the entry to remove from the cache */ void remove(CmsFlexCacheKey key) { if (!isEnabled()) { return; } Object o = m_keyCache.get(key.getResource()); if (o != null) { //Object old = ((HashMap)o).remove(key.Variation); Object old = ((HashMap)o).get(key.getVariation()); if (old != null) { getEntryLruCache().remove((I_CmsLruCacheObject)old); } } }
/** * Clears all entries from the online project in the cache.<p> * * The keys from the online project are not cleared. * Cached resources from the offline projects are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOnlineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_ONLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_ONLINESUFFIX, true); }
/** * Clears all entries from offline projects in the cache.<p> * * The keys from the offline projects are not cleared. * Cached resources from the online project are not touched.<p> * * Only users with administrator permissions are allowed * to perform this operation.<p> */ private void clearOfflineEntries() { if (!isEnabled()) { return; } if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_CLEAR_OFFLINE_ENTRIES_0)); } clearAccordingToSuffix(CACHE_OFFLINESUFFIX, true); }
/** * Adds a key with a new, empty variation map to the cache.<p> * * @param key the key to add to the cache. */ void putKey(CmsFlexCacheKey key) { if (!isEnabled()) { return; } Object o = m_keyCache.get(key.getResource()); if (o == null) { // No variation map for this resource yet, so create one CmsFlexCacheVariation variationMap = new CmsFlexCacheVariation(key); m_keyCache.put(key.getResource(), variationMap); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_ADD_KEY_1, key.getResource())); } } // If != null the key is already in the cache, so we just do nothing }
/** * Adds a key with a new, empty variation map to the cache.<p> * * @param key the key to add to the cache. */ void putKey(CmsFlexCacheKey key) { if (!isEnabled()) { return; } Object o = m_keyCache.get(key.getResource()); if (o == null) { // No variation map for this resource yet, so create one CmsFlexCacheVariation variationMap = new CmsFlexCacheVariation(key); m_keyCache.put(key.getResource(), variationMap); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHE_ADD_KEY_1, key.getResource())); } } // If != null the key is already in the cache, so we just do nothing }