本文整理汇总了Java中org.springframework.cache.interceptor.SimpleKey类的典型用法代码示例。如果您正苦于以下问题:Java SimpleKey类的具体用法?Java SimpleKey怎么用?Java SimpleKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleKey类属于org.springframework.cache.interceptor包,在下文中一共展示了SimpleKey类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Override
@Transactional
public void load(Ehcache ehcache) throws CacheException {
int i = 1, total = 12;
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", false, false), kmlService.getAllStagesKml("track", false, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", false, true), kmlService.getAllStagesKml("track", false, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", true, false), kmlService.getAllStagesKml("track", true, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", true, true), kmlService.getAllStagesKml("track", true, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", false, false), kmlService.getAllStagesKml("marcadores", false, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", false, true), kmlService.getAllStagesKml("marcadores", false, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", true, false), kmlService.getAllStagesKml("marcadores", true, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", true, true), kmlService.getAllStagesKml("marcadores", true, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", false, false), kmlService.getAllStagesKml("servicios", false, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", false, true), kmlService.getAllStagesKml("servicios", false, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", true, false), kmlService.getAllStagesKml("servicios", true, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", true, true), kmlService.getAllStagesKml("servicios", true, true), true));
log.info("Caching done!");
}
示例2: getSimple
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void getSimple() {
this.keyGenerator.expect(1L);
Object first = this.simpleService.get(1L);
Object second = this.simpleService.get(1L);
assertSame(first, second);
Object key = new SimpleKey(1L);
assertEquals(first, cache.get(key).get());
}
示例3: getFlattenVararg
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void getFlattenVararg() {
this.keyGenerator.expect(1L, "foo", "bar");
Object first = this.simpleService.get(1L, "foo", "bar");
Object second = this.simpleService.get(1L, "foo", "bar");
assertSame(first, second);
Object key = new SimpleKey(1L, "foo", "bar");
assertEquals(first, cache.get(key).get());
}
示例4: getFiltered
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void getFiltered() {
this.keyGenerator.expect(1L);
Object first = this.simpleService.getFiltered(1L, "foo", "bar");
Object second = this.simpleService.getFiltered(1L, "foo", "bar");
assertSame(first, second);
Object key = new SimpleKey(1L);
assertEquals(first, cache.get(key).get());
}
示例5: generate
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Override
public Object generate(Object target, Method method, Object... params) {
assertTrue("Unexpected parameters: expected: "
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params),
Arrays.equals(expectedParams, params));
return new SimpleKey(params);
}
示例6: whenFindAllThenBooksCached
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void whenFindAllThenBooksCached() {
List<Book> books = bookService.findAll();
assertThat(books).isNotNull();
assertThat(bookService.getCounterFindAll()).isEqualTo(1);
bookService.findAll();
bookService.findAll();
assertThat(bookService.getCounterFindAll()).isEqualTo(1);
Object value = cacheManager.getCache("books").get(SimpleKey.EMPTY);
assertThat(value).isNotNull();
}
示例7: whenClearThenOnlyBooksEvicted
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void whenClearThenOnlyBooksEvicted() {
bookService.findAll();
authorService.findAll();
bookService.clear();
Object value = cacheManager.getCache("books").get(SimpleKey.EMPTY);
assertThat(value).isNull();
value = cacheManager.getCache("authors").get(SimpleKey.EMPTY);
assertThat(value).isNotNull();
}
示例8: generate
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Override
public Object generate(Object target, Method method, Object... params) {
params = ArrayUtils.add(params, 0, method.getName());
if (params.length == 1) {
return params[0];
}
return new SimpleKey(params);
}
示例9: generateKey
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
/**
* Generate a key based on the specified parameters.
*/
public static Object generateKey(Object... params) {
if (params.length == 0) {
return SimpleKey.EMPTY;
}
if (params.length == 1) {
Object param = params[0];
if (param != null && Variant.class.isInstance(param)) {
return generateVariantKey((Variant) param);
}
}
return new SimpleKey(params);
}
示例10: returnsSimpleKeyForManyThings
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void returnsSimpleKeyForManyThings() throws Exception {
Object object1 = new Object();
Object object2 = new Object();
assertThat(instance.generate(new Object(), Object.class.getMethod("toString"), object1, object2), equalTo(new SimpleKey(object1, object2)));
}
示例11: generateKey
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Override
public Object generateKey(Object target, Method method, Object... params) {
if (params.length == 1) {
AwsCredentialView param = (AwsCredentialView) params[0];
if (param.getId() != null) {
return param.getId();
} else {
return SimpleKey.EMPTY;
}
}
return SimpleKey.EMPTY;
}
示例12: returnsEmptyKeyForEmptyQuery
import org.springframework.cache.interceptor.SimpleKey; //导入依赖的package包/类
@Test
public void returnsEmptyKeyForEmptyQuery() throws Exception {
assertThat(instance.generate(new Object(), Object.class.getMethod("toString")), equalTo(SimpleKey.EMPTY));
}