本文整理了Java中org.springframework.cache.Cache.evict()
方法的一些代码示例,展示了Cache.evict()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.evict()
方法的具体详情如下:
包路径:org.springframework.cache.Cache
类名称:Cache
方法名:evict
[英]Evict the mapping for this key from this cache if it is present.
[中]如果此密钥存在,请从此缓存中退出该密钥的映射。
代码示例来源:origin: spring-projects/spring-framework
@Override
public void afterCommit() {
TransactionAwareCacheDecorator.this.targetCache.evict(key);
}
});
代码示例来源:origin: spring-projects/spring-security
public void removeUserFromCache(String username) {
cache.evict(username);
}
}
代码示例来源:origin: spring-projects/spring-security
public void removeTicketFromCache(final String serviceTicket) {
cache.evict(serviceTicket);
}
}
代码示例来源:origin: org.springframework/spring-context-support
@Override
public void afterCommit() {
TransactionAwareCacheDecorator.this.targetCache.evict(key);
}
});
代码示例来源:origin: org.springframework.security/spring-security-core
public void removeUserFromCache(String username) {
cache.evict(username);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Execute {@link Cache#evict(Object)} on the specified {@link Cache} and
* invoke the error handler if an exception occurs.
*/
protected void doEvict(Cache cache, Object key) {
try {
cache.evict(key);
}
catch (RuntimeException ex) {
getErrorHandler().handleCacheEvictError(ex, cache, key);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void evict(final Object key) {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
TransactionAwareCacheDecorator.this.targetCache.evict(key);
}
});
}
else {
this.targetCache.evict(key);
}
}
代码示例来源:origin: spring-projects/spring-security
public void evictFromCache(Serializable pk) {
Assert.notNull(pk, "Primary key (identifier) required");
MutableAcl acl = getFromCache(pk);
if (acl != null) {
cache.evict(acl.getId());
cache.evict(acl.getObjectIdentity());
}
}
代码示例来源:origin: spring-projects/spring-security
public void evictFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");
MutableAcl acl = getFromCache(objectIdentity);
if (acl != null) {
cache.evict(acl.getId());
cache.evict(acl.getObjectIdentity());
}
}
代码示例来源:origin: org.springframework/spring-context
/**
* Execute {@link Cache#evict(Object)} on the specified {@link Cache} and
* invoke the error handler if an exception occurs.
*/
protected void doEvict(Cache cache, Object key) {
try {
cache.evict(key);
}
catch (RuntimeException ex) {
getErrorHandler().handleCacheEvictError(ex, cache, key);
}
}
代码示例来源:origin: org.springframework/spring-context-support
@Override
public void evict(final Object key) {
if (TransactionSynchronizationManager.isSynchronizationActive()) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
TransactionAwareCacheDecorator.this.targetCache.evict(key);
}
});
}
else {
this.targetCache.evict(key);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void evictFailProperException() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
willThrow(exception).given(this.cache).evict(0L);
this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler());
this.thrown.expect(is(exception));
this.simpleService.evict(0L);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void evictFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
willThrow(exception).given(this.cache).evict(0L);
this.simpleService.evict(0L);
verify(this.errorHandler).handleCacheEvictError(exception, cache, 0L);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void evictNonTransactional() {
Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object();
cache.put(key, "123");
cache.evict(key);
assertNull(target.get(key));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void evictFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(this.cache).evict(key);
this.simpleService.evict(0L);
verify(this.errorHandler).handleCacheEvictError(exception, this.cache, key);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void evictTransactional() {
Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object();
cache.put(key, "123");
TransactionStatus status = this.txManager.getTransaction(
new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED));
cache.evict(key);
assertEquals("123", target.get(key, String.class));
this.txManager.commit(status);
assertNull(target.get(key));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testDynamicMode() {
CacheManager cm = new CaffeineCacheManager();
Cache cache1 = cm.getCache("c1");
assertTrue(cache1 instanceof CaffeineCache);
Cache cache1again = cm.getCache("c1");
assertSame(cache1again, cache1);
Cache cache2 = cm.getCache("c2");
assertTrue(cache2 instanceof CaffeineCache);
Cache cache2again = cm.getCache("c2");
assertSame(cache2again, cache2);
Cache cache3 = cm.getCache("c3");
assertTrue(cache3 instanceof CaffeineCache);
Cache cache3again = cm.getCache("c3");
assertSame(cache3again, cache3);
cache1.put("key1", "value1");
assertEquals("value1", cache1.get("key1").get());
cache1.put("key2", 2);
assertEquals(2, cache1.get("key2").get());
cache1.put("key3", null);
assertNull(cache1.get("key3").get());
cache1.evict("key3");
assertNull(cache1.get("key3"));
}
代码示例来源:origin: spring-projects/spring-framework
cache1.put("key3", null);
assertNull(cache1.get("key3").get());
cache1.evict("key3");
assertNull(cache1.get("key3"));
cache1y.evict("key3");
assertNull(cache1y.get("key3"));
代码示例来源:origin: spring-projects/spring-framework
cache1.put("key3", null);
assertNull(cache1.get("key3").get());
cache1.evict("key3");
assertNull(cache1.get("key3"));
assertNull(cache1.putIfAbsent("key3", null).get());
assertNull(cache1.get("key3").get());
cache1.evict("key3");
assertNull(cache1.get("key3"));
代码示例来源:origin: spring-projects/spring-framework
cache1.put("key3", null);
assertNull(cache1.get("key3").get());
cache1.evict("key3");
assertNull(cache1.get("key3"));
cache1y.evict("key3");
assertNull(cache1y.get("key3"));
内容来源于网络,如有侵权,请联系作者删除!