本文整理了Java中org.springframework.cache.Cache.getNativeCache()
方法的一些代码示例,展示了Cache.getNativeCache()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getNativeCache()
方法的具体详情如下:
包路径:org.springframework.cache.Cache
类名称:Cache
方法名:getNativeCache
[英]Return the underlying native cache provider.
[中]返回基础本机缓存提供程序。
代码示例来源:origin: spring-projects/spring-framework
@Override
public Object getNativeCache() {
return this.targetCache.getNativeCache();
}
代码示例来源:origin: org.springframework/spring-context-support
@Override
public Object getNativeCache() {
return this.targetCache.getNativeCache();
}
代码示例来源:origin: spring-projects/spring-framework
protected boolean isEmpty(Cache cache) {
ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
return nativeCache.isEmpty();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
if (!nativeCache.isEmpty()) {
throw new AssertionError("Cache was expected to be empty");
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
if (!nativeCache.isEmpty()) {
throw new AssertionError("Cache was expected to be empty");
}
}
代码示例来源: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: apache/kylin
@Override
public void run() {
Cache cache = getCache(CacheConstants.QUERY_CACHE);
MemcachedClientIF cacheClient = (MemcachedClientIF) cache.getNativeCache();
Collection<SocketAddress> liveServers = cacheClient.getAvailableServers();
Collection<SocketAddress> deadServers = cacheClient.getUnavailableServers();
if (liveServers.size() == 0) {
clusterHealth.set(false);
logger.error("All the servers in MemcachedCluster is down, UnavailableServers: " + deadServers);
} else {
clusterHealth.set(true);
if (deadServers.size() > liveServers.size()) {
logger.warn("Half of the servers in MemcachedCluster is down, LiveServers: " + liveServers
+ ", UnavailableServers: " + deadServers);
}
}
}
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<SdkKey> getCachedSdkKeys(String applicationId) {
List<SdkKey> keys = new ArrayList<>();
Ehcache cache = (Ehcache) adminCacheManager.getCache(SDK_CACHE).getNativeCache();
List<?> cachedKeys = cache.getKeysWithExpiryCheck();
for (Object cachedKey : cachedKeys) {
if (cachedKey instanceof SdkKey) {
SdkKey cachedSdkKey = (SdkKey) cachedKey;
if (applicationId.equals(cachedSdkKey.getSdkProfile().getApplicationId())) {
keys.add(cachedSdkKey);
}
}
}
return keys;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testNativeCache() throws Exception {
assertSame(getNativeCache(), getCache().getNativeCache());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testNoOpCache() throws Exception {
String name = createRandomKey();
Cache cache = this.manager.getCache(name);
assertEquals(name, cache.getName());
Object key = new Object();
cache.put(key, new Object());
assertNull(cache.get(key));
assertNull(cache.get(key, Object.class));
assertSame(cache, cache.getNativeCache());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void regularOperationsOnTarget() {
Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target);
assertEquals(target.getName(), cache.getName());
assertEquals(target.getNativeCache(), cache.getNativeCache());
Object key = new Object();
target.put(key, "123");
assertEquals("123", cache.get(key).get());
assertEquals("123", cache.get(key, String.class));
cache.clear();
assertNull(target.get(key));
}
代码示例来源:origin: spring-projects/spring-security
public void cacheOperationsAclWithParent() throws Exception {
Cache cache = getCache();
Map realCache = (Map) cache.getNativeCache();
代码示例来源:origin: spring-projects/spring-security
public void cacheOperationsAclWithoutParent() throws Exception {
Cache cache = getCache();
Map realCache = (Map) cache.getNativeCache();
ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(100));
AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
public CacheEntry(Cache cache, String cacheManager) {
super(cache.getNativeCache().getClass().getName());
this.name = cache.getName();
this.cacheManager = cacheManager;
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-autoconfigure
/**
* @return
* @see org.springframework.cache.Cache#getNativeCache()
*/
@Override
public Object getNativeCache() {
return delegate.getNativeCache();
}
代码示例来源:origin: cn.jeeweb/jeeweb-common-security
@Override
public int size() {
if (springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return ehcache.getSize();
}
throw new UnsupportedOperationException("invoke spring cache abstract size method not supported");
}
代码示例来源:origin: huangjian888/jeeweb-mybatis-springboot
@Override
public Set keys() {
if (springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return new HashSet(ehcache.getKeys());
}
throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
}
代码示例来源:origin: cn.jeeweb/jeeweb-common-security
@Override
public Set keys() {
if (springCache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) springCache.getNativeCache();
return new HashSet(ehcache.getKeys());
}
throw new UnsupportedOperationException("invoke spring cache abstract keys method not supported");
}
代码示例来源:origin: NationalSecurityAgency/datawave
private int countCacheEntries() {
CacheManager cacheManager = this.applicationContext.getBean("dateIndexHelperCacheManager", CacheManager.class);
String cacheName = "getTypeDescription";
Object nativeCache = cacheManager.getCache(cacheName).getNativeCache();
Cache cache = (Cache) nativeCache;
Map map = cache.asMap();
return map.size();
}
内容来源于网络,如有侵权,请联系作者删除!