@Test public void executeWithDifferentMaxEntries() throws Exception { CacheMacroParameters params = new CacheMacroParameters(); MacroTransformationContext context = createMacroTransformationContext(); params.setId("id"); params.setMaxEntries(10); params.setTimeToLive(100); List<Block> result1 = this.cacheMacro.execute(params, "content1", context); params.setMaxEntries(11); List<Block> result2 = this.cacheMacro.execute(params, "content2", context); assertFalse(result2.equals(result1)); }
@Override public List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { String cacheKey; if (parameters.getId() != null) { WikiPrinter printer = new DefaultWikiPrinter(); this.plainTextBlockRenderer.render(this.contentParser.parse(parameters.getId(), context, true, false), printer); cacheKey = printer.toString(); } else { cacheKey = content; } Cache<List<Block>> contentCache = getContentCache(parameters.getTimeToLive(), parameters.getMaxEntries()); List<Block> result = contentCache.get(cacheKey); if (result == null) { result = this.contentParser.parse(content, context, true, context.isInline()).getChildren(); contentCache.set(cacheKey, result); } return result; }
CacheMacro extends AbstractMacro<CacheMacroParameters> { @Override public List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { String cacheKey; if (parameters.getId() != null) { WikiPrinter printer = new DefaultWikiPrinter(); this.plainTextBlockRenderer.render(this.contentParser.parse(parameters.getId(), context, true, false), printer); cacheKey = printer.toString(); } else { cacheKey = content; } Cache<List<Block>> contentCache = getContentCache(parameters.getTimeToLive(), parameters.getMaxEntries()); List<Block> result = contentCache.get(cacheKey); if (result == null) { result = this.contentParser.parse(content, context, true, context.isInline()).getChildren(); contentCache.set(cacheKey, result); } return result; } }
CacheMacro extends AbstractMacro<CacheMacroParameters> { @Override public List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { String cacheKey; if (parameters.getId() != null) { WikiPrinter printer = new DefaultWikiPrinter(); this.plainTextBlockRenderer.render(this.contentParser.parse(parameters.getId(), context, true, false), printer); cacheKey = printer.toString(); } else { cacheKey = content; } Cache<List<Block>> contentCache = getContentCache(parameters.getTimeToLive(), parameters.getMaxEntries()); List<Block> result = contentCache.get(cacheKey); if (result == null) { result = this.contentParser.parse(content, context, true, context.isInline()).getChildren(); contentCache.set(cacheKey, result); } return result; } CacheMacro(); }
CacheMacro extends AbstractMacro<CacheMacroParameters> { @Override public List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { String cacheKey; if (parameters.getId() != null) { WikiPrinter printer = new DefaultWikiPrinter(); this.plainTextBlockRenderer.render(this.contentParser.parse(parameters.getId(), context, true, false), printer); cacheKey = printer.toString(); } else { cacheKey = content; } Cache<List<Block>> contentCache = getContentCache(parameters.getTimeToLive(), parameters.getMaxEntries()); List<Block> result = contentCache.get(cacheKey); if (result == null) { result = this.contentParser.parse(content, context, true, context.isInline()).getChildren(); contentCache.set(cacheKey, result); } return result; } CacheMacro(); @Override boolean supportsInlineMode(); @Override List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context); }
CacheMacro extends AbstractMacro<CacheMacroParameters> { @Override public List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { String cacheKey; if (parameters.getId() != null) { WikiPrinter printer = new DefaultWikiPrinter(); this.plainTextBlockRenderer.render(this.contentParser.parse(parameters.getId(), context, true, false), printer); cacheKey = printer.toString(); } else { cacheKey = content; } Cache<List<Block>> contentCache = getContentCache(parameters.getTimeToLive(), parameters.getMaxEntries()); List<Block> result = contentCache.get(cacheKey); if (result == null) { result = this.contentParser.parse(content, context, true, context.isInline()).getChildren(); contentCache.set(cacheKey, result); } return result; } CacheMacro(); @Override boolean supportsInlineMode(); @Override List<Block> execute(CacheMacroParameters parameters, String content, MacroTransformationContext context);  }