本文整理汇总了Java中org.springframework.cache.interceptor.SimpleKeyGenerator.generateKey方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleKeyGenerator.generateKey方法的具体用法?Java SimpleKeyGenerator.generateKey怎么用?Java SimpleKeyGenerator.generateKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cache.interceptor.SimpleKeyGenerator
的用法示例。
在下文中一共展示了SimpleKeyGenerator.generateKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFail
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Test
public void getFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(cache).get(key);
this.simpleService.get(0L);
verify(errorHandler).handleCacheGetError(exception, cache, key);
}
示例2: putFail
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Test
public void putFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on put");
Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(cache).put(key, 234L);
this.simpleService.put(0L, 234L);
verify(errorHandler).handleCachePutError(exception, cache, key, 234L);
}
示例3: evictFail
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Test
public void evictFail() {
UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict");
Object key = SimpleKeyGenerator.generateKey(0L);
willThrow(exception).given(cache).evict(key);
this.simpleService.evict(0L);
verify(errorHandler).handleCacheEvictError(exception, cache, key);
}
示例4: earlyPut
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
Object key = SimpleKeyGenerator.generateKey(id);
Cache.ValueWrapper valueWrapper = defaultCache.get(key);
if (valueWrapper == null) {
throw new AssertionError("Excepted value to be put in cache with key " + key);
}
Object actual = valueWrapper.get();
if (value != actual) { // instance check on purpose
throw new AssertionError("Wrong value set in cache with key " + key + ". " +
"Expected=" + value + ", but got=" + actual);
}
}
示例5: earlyRemove
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Override
@CacheRemove(afterInvocation = false)
public void earlyRemove(String id) {
Object key = SimpleKeyGenerator.generateKey(id);
Cache.ValueWrapper valueWrapper = defaultCache.get(key);
if (valueWrapper != null) {
throw new AssertionError("Value with key " + key + " expected to be already remove from cache");
}
}
示例6: generate
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Override
// Exception squid:S923 - override
@SuppressWarnings({ "squid:S923" })
public Object generate(final Object target, final Method method, final Object... params) {
final String initialTenantCreation = createInitialTenant.get();
if (initialTenantCreation == null) {
return SimpleKeyGenerator.generateKey(tenantAware.getCurrentTenant().toUpperCase(),
tenantAware.getCurrentTenant().toUpperCase());
}
return SimpleKeyGenerator.generateKey(initialTenantCreation.toUpperCase(),
initialTenantCreation.toUpperCase());
}
示例7: generate
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
@Override
public Object generate(Object target, Method method, Object... params) {
if (params.length == 1) {
CacheDefinition cacheDefinition = classCacheDefinitionMap.get(params[0].getClass());
if (cacheDefinition != null) {
return cacheDefinition.generateKey(target, method, params);
}
}
return SimpleKeyGenerator.generateKey(params);
}
示例8: createKey
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
private Object createKey(Object... params) {
return SimpleKeyGenerator.generateKey(params);
}
示例9: generateKey
import org.springframework.cache.interceptor.SimpleKeyGenerator; //导入方法依赖的package包/类
default Object generateKey(Object target, Method method, Object... params) {
return SimpleKeyGenerator.generateKey(params);
}