本文整理了Java中net.sf.ehcache.Cache.getKeys()
方法的一些代码示例,展示了Cache.getKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getKeys()
方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:getKeys
[英]Returns a list of all element keys in the cache, whether or not they are expired.
The returned keys are unique and can almost be considered a set. See net.sf.ehcache.store.CacheKeySet for more details.
The List returned is not live. It is a copy.
The time taken is O(n). On a single CPU 1.8Ghz P4, approximately 8ms is required for each 1000 entries.
[中]返回缓存中所有元素键的列表,无论它们是否过期。
返回的密钥是唯一的,几乎可以视为一个集合。见网。旧金山。ehcache。百货商店有关更多详细信息,请参阅CacheKeySet。
返回的列表不是活动列表。这是一份副本。
所用时间为O(n)。在单CPU 1.8Ghz P4上,每1000个条目大约需要8ms。
代码示例来源:origin: jfinal/jfinal
@SuppressWarnings("rawtypes")
public static List getKeys(String cacheName) {
return getOrAddCache(cacheName).getKeys();
}
代码示例来源:origin: stylefeng/Guns
public static List getKeys(String cacheName) {
return getOrAddCache(cacheName).getKeys();
}
代码示例来源:origin: shopizer-ecommerce/shopizer
public List<String> getCacheKeys(MerchantStore store) throws Exception {
net.sf.ehcache.Cache cacheImpl = (net.sf.ehcache.Cache) cache.getNativeCache();
List<String> returnKeys = new ArrayList<String>();
for (Object key: cacheImpl.getKeys()) {
try {
String sKey = (String)key;
// a key should be <storeId>_<rest of the key>
int delimiterPosition = sKey.indexOf(KEY_DELIMITER);
if(delimiterPosition>0 && Character.isDigit(sKey.charAt(0))) {
String keyRemaining = sKey.substring(delimiterPosition+1);
returnKeys.add(keyRemaining);
}
} catch (Exception e) {
LOGGER.equals("key " + key + " cannot be converted to a String or parsed");
}
}
return returnKeys;
}
代码示例来源:origin: shopizer-ecommerce/shopizer
public void removeAllFromCache(MerchantStore store) throws Exception {
net.sf.ehcache.Cache cacheImpl = (net.sf.ehcache.Cache) cache.getNativeCache();
for (Object key: cacheImpl.getKeys()) {
try {
String sKey = (String)key;
// a key should be <storeId>_<rest of the key>
int delimiterPosition = sKey.indexOf(KEY_DELIMITER);
if(delimiterPosition>0 && Character.isDigit(sKey.charAt(0))) {
cache.evict(key);
}
} catch (Exception e) {
LOGGER.equals("key " + key + " cannot be converted to a String or parsed");
}
}
}
代码示例来源:origin: javamelody/javamelody
private void clearCacheKey(String cacheId, String cacheKey) {
final List<CacheManager> allCacheManagers = CacheManager.ALL_CACHE_MANAGERS;
for (final CacheManager cacheManager : allCacheManagers) {
final Cache cache = cacheManager.getCache(cacheId);
if (cache != null) {
final boolean removed = cache.remove(cacheKey);
if (!removed) {
// if keys are not Strings, we have to find the initial key
for (final Object key : cache.getKeys()) {
if (key != null && key.toString().equals(cacheKey)) {
cache.remove(key);
break;
}
}
}
}
}
}
代码示例来源:origin: banq/jdonframework
public Collection keySet() {
Cache cache = manager.getCache(ehcacheConf.getPredefinedCacheName());
return cache.getKeys();
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Returns a list of all elements in the cache, whether or not they are expired.
* <p>
* The returned keys are not unique and may contain duplicates. If the cache is only
* using the memory store, the list will be unique. If the disk store is being used
* as well, it will likely contain duplicates, because of the internal store design.
* <p>
* The List returned is not live. It is a copy.
* <p>
* The time taken is O(log n). On a single CPU 1.8Ghz P4, approximately 6ms is required
* for 1000 entries and 36 for 50000.
* <p>
* This is the fastest getKeys method
*
* @return a list of {@link Object} keys
* @throws IllegalStateException if the cache is not {@link Status#STATUS_ALIVE}
*/
public final List getKeysNoDuplicateCheck() throws IllegalStateException {
checkStatus();
return getKeys();
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* An extremely expensive check to see if the value exists in the cache. This implementation is O(n). Ehcache
* is not designed for efficient access in this manner.
* <p>
* This method is not synchronized. It is possible that an element may exist in the cache and be removed
* before the check gets to it, or vice versa. Because it is slow to execute the probability of that this will
* have happened.
*
* @param value to check for
* @return true if an Element matching the key is found in the cache. No assertions are made about the state of the Element.
*/
public boolean isValueInCache(Object value) {
for (Object key : getKeys()) {
Element element = get(key);
if (element != null) {
Object elementValue = element.getValue();
if (elementValue == null) {
if (value == null) {
return true;
}
} else {
if (elementValue.equals(value)) {
return true;
}
}
}
}
return false;
}
代码示例来源:origin: net.sf.ehcache/ehcache
List allKeyList = getKeys();
代码示例来源:origin: justlive1/oxygen
@SuppressWarnings("unchecked")
@Override
public Collection<String> keys() {
return cache.getKeys();
}
代码示例来源:origin: deas/alfresco
@SuppressWarnings("unchecked")
public Collection<K> getKeys()
{
return cache.getKeys();
}
代码示例来源:origin: lutece-platform/lutece-core
/**
* {@inheritDoc }
*/
@Override
public List<String> getKeys( )
{
if ( _cache != null )
{
return _cache.getKeys( );
}
return new ArrayList<String>( );
}
代码示例来源:origin: edu.ucar/netcdf
public void showKeys() {
List keys = cache.getKeys();
Collections.sort(keys);
for (Object key : keys) {
Element elem = cache.get(key);
System.out.printf(" %40s == %s%n", key, elem);
}
}
代码示例来源:origin: kingbbode/spring-boot-ehcache-monitor
@SuppressWarnings("unchecked")
private List<?> getKeys(Cache ehcache, String keyword) {
return (List<?>) ehcache.getKeys()
.stream()
.filter(o -> o instanceof String)
.filter(o -> ((String) o).contains(keyword))
.collect(Collectors.toList());
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
public Set<String> listPropertyNames() {
Set < String > propertyNames = new HashSet<String>();
for (Object key : wrapper.getCacheProperties().getKeys()) {
propertyNames.add((String) key);
}
return propertyNames;
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public Set<String> listCachedPropertyNames() {
return new HashSet<String>(getCacheProperties().getKeys());
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public Set<String> listCachedFeatureNames() {
return new HashSet<String>(getCacheFeatures().getKeys());
}
代码示例来源:origin: com.intuit.wasabi/wasabi-assignment
/**
* Get the cache keys
*
* @param cacheName
* @return cache keys
*/
private Collection keys(CACHE_NAME cacheName) {
return cacheManager.getCache(cacheName.name()).getKeys();
}
代码示例来源:origin: yangfuhai/jboot
@Override
public List getKeys(String cacheName) {
return getOrAddCache(cacheName).getKeys();
}
代码示例来源:origin: caojx-git/learn
@Cacheable(value = "myCache", key = "")
public List<UserInfo> getUsers() {
Cache cache = ehCacheService.getCache("myCache");
System.out.println("cache.getKeys()="+cache.getKeys());
return userInfoDAO.query(new UserInfo());
}
内容来源于网络,如有侵权,请联系作者删除!