Cache Extension
Cache Extension
Related documents
1 Motivations
In the previous versions of eXo kernel, it was quite complex to implement your own ExoCache because it was not open enough. Since kernel 2.0.8, it is possible to easily integrate your favorite cache provider in eXo Products. In fact in previous versions, you could only use few properties provided by ExoCachConfig to create your cache, as you can see below:package org.exoplatform.services.cache; ... public class ExoCacheConfig { /** * The name of the cache */ private String name; /** * The label of the cache */ private String label; /** * The maximum number of elements in your cache */ private int maxSize; /** * The amount of time (in milliseconds) an element is not written or * read before it is evicted. */ private long liveTime; /** * Indicates if the cache is distributed */ private boolean distributed; /** * Indicates if the cache is replicated */ private boolean replicated; /** * The full qualified name of the cache implementation to use */ private String implementation; /** * Indicates if the log is enabled */ private boolean logEnabled; ...
2 Overview
Since kernel 2.0.8, you just need to implement your own ExoCacheFactory and register it in an eXo container (as described here?), described below:package org.exoplatform.services.cache; ... public interface ExoCacheFactory { /** * Creates a new instance of {@link org.exoplatform.services.cache.ExoCache} * @param config the cache to create * @return the new instance of {@link org.exoplatform.services.cache.ExoCache} * @exception ExoCacheInitException if an exception happens while initializing the cache */ public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException; }
<?xml version="1.0" encoding="ISO-8859-1"?> <configuration> <component> <key>org.exoplatform.services.cache.ExoCacheFactory</key> <type>org.exoplatform.tutorial.MyExoCacheFactoryImpl</type> ... </component> </configuration>