Skip to content

Commit

Permalink
SAK-26113 remove ehcache from rwiki as the RenderCache doesn't appear…
Browse files Browse the repository at this point in the history
… to help much

git-svn-id: https://source.sakaiproject.org/svn/rwiki/trunk@308534 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
ottenhoff committed Apr 23, 2014
1 parent 47aa499 commit 4ee1655
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,4 @@ public interface RenderContext
* Map of parameters with name,value pairs
*/
public void setParameters(Map parameters);

public void setCacheable(boolean cacheable);

public void commitCache();

public boolean isCacheable();
}

This file was deleted.

4 changes: 0 additions & 4 deletions rwiki/rwiki-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@
<artifactId>hibernate-core</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import uk.ac.cam.caret.sakai.rwiki.service.api.RenderService;
import uk.ac.cam.caret.sakai.rwiki.service.api.model.RWikiObject;
import uk.ac.cam.caret.sakai.rwiki.service.api.radeox.CachableRenderContext;
import uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderCache;
import uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderContextFactory;
import uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderEngineFactory;
import uk.ac.cam.caret.sakai.rwiki.utils.TimeLogger;
Expand All @@ -48,8 +47,6 @@ public class RenderServiceImpl implements RenderService

private RenderContextFactory renderContextFactory;

private RenderCache renderCache;

public void init()
{
ComponentManager cm = org.sakaiproject.component.cover.ComponentManager
Expand All @@ -58,8 +55,6 @@ public void init()
.getName());

renderContextFactory = (RenderContextFactory) load(cm, RenderContextFactory.class.getName());
renderCache = (RenderCache) load(cm, RenderCache.class
.getName());
}

private Object load(ComponentManager cm, String name)
Expand All @@ -79,25 +74,8 @@ public String renderPage(RWikiObject rwo, String pageSpace,

long start = System.currentTimeMillis();
String renderedPage = null;
String cacheKey = getCacheKey(rwo, plr);
try
{
if (plr.canUseCache() && renderCache != null)
{
renderedPage = renderCache.getRenderedContent(cacheKey);
if (renderedPage != null)
{
if (TimeLogger.getLogResponse())
log.info("Cache HIT " + cacheKey);
else
log.debug("Cache HIT " + cacheKey);
return renderedPage;
}
}
else
{
log.debug("Render Cache Disabled");
}
RenderEngine renderEngine = renderEngineFactory.getRenderEngine(
pageSpace, plr);
RenderContext renderContext = renderContextFactory
Expand All @@ -107,34 +85,6 @@ public String renderPage(RWikiObject rwo, String pageSpace,
{
renderedPage = "<p class=\"paragraph\">"+renderedPage+"</p>";
}
boolean canCache = false;
if (renderContext instanceof CachableRenderContext)
{
CachableRenderContext crc = (CachableRenderContext) renderContext;
canCache = crc.isCachable();
}
if (canCache && plr.isCachable() && plr.canUseCache())
{
if (renderCache != null)
{
renderCache.putRenderedContent(cacheKey, renderedPage);
if (TimeLogger.getLogResponse())
log.info("Cache PUT " + cacheKey);
else
log.debug("Cache PUT " + cacheKey);
}
else
{
log.debug("Could have cached output");
}
}
else
{
if (TimeLogger.getLogResponse())
log.info("Cant Cache " + cacheKey);
else
log.debug("Cant Cache " + cacheKey);
}
return renderedPage;
}
finally
Expand All @@ -144,21 +94,4 @@ public String renderPage(RWikiObject rwo, String pageSpace,
}
}


/**
* Generates a key for the page taking into account the page, version and
* link render mecahnism
*
* @param rwo
* @param plr
* @return
*/
public String getCacheKey(RWikiObject rwo, PageLinkRenderer plr)
{
String classNameHash = plr.getClass().getName();
classNameHash = classNameHash.substring(classNameHash.lastIndexOf("."));
return rwo.getId() + "." + rwo.getVersion().getTime() + "."
+ classNameHash;
}

}
23 changes: 0 additions & 23 deletions rwiki/rwiki-impl/pack/src/webapp/WEB-INF/coreServiceComponents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,6 @@
>
</bean>



<!-- The Rendered content cache, impl uses ehcache which is initialised on first use, if cache fails
it is re-initialised -->
<bean id="uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderCache"
class="uk.ac.cam.caret.sakai.rwiki.component.radeox.service.impl.RenderCacheImpl"
init-method="init" >
<property name="cache"><ref bean="uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderCache.cache" /></property>
</bean>

<bean id="uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderCache.cache"
class="org.sakaiproject.memory.util.EhCacheFactoryBean">
<property name="cacheManager"><ref bean="org.sakaiproject.memory.api.MemoryService.cacheManager"/></property>
<property name="cacheName"><value>uk.ac.cam.caret.sakai.rwiki.service.api.radeox.RenderCache</value></property>
<property name="maxElementsInMemory" ><value>10000</value></property>
<property name="diskPersistent" ><value>false</value></property>
<property name="eternal" ><value>false</value></property>
<property name="timeToLive" ><value>300</value></property>
<property name="timeToIdle" ><value>600</value></property>
</bean>



<bean id="rwikiRAWHandler"
class="uk.ac.cam.caret.sakai.rwiki.component.service.impl.XSLTEntityHandler"
init-method="init" destroy-method="destroy" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@

public class BaseRenderContext implements RenderContext
{
private boolean cacheable = true;

private boolean tempCacheable = false;;

private RenderEngine engine;

private Map params;
Expand Down Expand Up @@ -84,19 +80,4 @@ public void setRenderEngine(RenderEngine engine)
this.engine = engine;
}

public void setCacheable(boolean cacheable)
{
tempCacheable = cacheable;
}

public void commitCache()
{
cacheable = cacheable && tempCacheable;
tempCacheable = false;
}

public boolean isCacheable()
{
return cacheable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,7 @@ public String filter(String input, FilterContext context)
Filter f = (Filter) filterIterator.next();
try
{
// assume all filters non cacheable
if (f instanceof CacheFilter)
{
renderContext.setCacheable(true);
}
else
{
renderContext.setCacheable(false);
}
String tmp = f.filter(output, context);
if (output.equals(tmp))
{
renderContext.setCacheable(true);
}
if (null == tmp)
{
log.warn("FilterPipe.filter: error while filtering: " + f);
Expand All @@ -208,7 +195,6 @@ public String filter(String input, FilterContext context)
{
output = tmp;
}
renderContext.commitCache();
}
catch (Exception e)
{
Expand All @@ -222,4 +208,4 @@ public Filter getFilter(int index)
{
return (Filter) filterList.get(index);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ protected String getLocaleKey()
return "filter.linktest"; //$NON-NLS-1$
}

protected void setUp(FilterContext context)
{
context.getRenderContext().setCacheable(true);
}

public void handleMatch(StringBuffer buffer, MatchResult result,
FilterContext context)
{
Expand Down Expand Up @@ -228,9 +223,6 @@ else if (wikiEngine.showCreate())
view = alias;
}
wikiEngine.appendCreateLink(buffer, name, view);
// links with "create" are not cacheable because
// a missing wiki could be created
context.getRenderContext().setCacheable(false);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,4 @@ public void testInterWikiExpander()
writer.toString());
}

public void testCacheable()
{
RenderContext renderContext = context.getRenderContext();
renderContext.setCacheable(false);
filter.filter("[stephan@SnipSnap]", context);
assertTrue("InterWiki is cacheable", renderContext.isCacheable());
}
}
Loading

0 comments on commit 4ee1655

Please sign in to comment.