I just created a page on design space: http://dev.xwiki.org/xwiki/bin/view/Design/XWikiCacheComponent On Tue, May 27, 2008 at 12:24 PM, Thomas Mortagne <[email protected]> wrote:
Hi Vincent,
I already sent a mail (http://markmail.org/message/euavqzjz53mxxkut) explaining the cache service -> cache components I planned/coded. You can find a first api and a complete oscache implementation at http://jira.xwiki.org/jira/browse/XWIKI-2359.
I designed this api looking to all places we used the old cache service and all this used to support. Lets list here the main lines of it :
1) What the new api already contains (see http://jira.xwiki.org/jira/browse/XWIKI-2359) : 1.1) First of all, there is two different component roles : * cache : create named cache that can be local or distributed caches depends on the implementation and its configuration. Typically used for documents cache. * local cache : create only and always local caches seems to be needed by some part of XWiki core like groovy, feed plugin and image plugin That way we can set in the configuration that we want memcached for normal cache and JBossCache for local cache for example.
1.2) Factory create cache and take parameters like "capacity"
1.3) Cache contains : * get : get the value by key, can take a timing as parameter compared to the time the value was registered the last time * set : modify or add a value to the cache * remove : remove a value from the cache
1.4) Cache can call listeners on add, delete, update...
1.5) Cache support generics
This api support all you listed I think (except for the way the timed cache works). It is generally based on the old cache services concepts even all the names changes but the more I'm working with JBoss cache the more I think this api need some changes as JBoss cache and OSCache has very different way to create there caches.
2) Problems/not sure yet : 2.1) old cache service provide methods taking maps of properties as parameters need by image plugin for example. My problem here is that all existing cache frameworks like OSCache, JBoss etc... are very new to me and I'm not sure of what feature I can generalize in this map. I think of starting by taking all properties setted by image plugin and list them as XWiki Cache properties and translate them for each implementations. Capacity, name all Factory take as parameters should be included in a CacheConfiguration object. Some of theses properties can also be ignored by implementation in some cases. 2.2) I think I need to change the way the timing works in this api as I did not find how to support it in JBoss yet. A more restrictive way and supported by JBoss would be to provided the limit time for the whole cache. I don"t really see a need for more. I'm thinking of introduce eviction algorithms concept like JBoss or cache4j do to replace the way restriction like capacity and timing are supported.
3) Other features the cache component could support for XWiki needs 3.1) for documents cache, Ludovic proposed the idea of something like a "meta cache" when we are using distributed cache: the idea is to only store the documents version in the distributed cache and store the reall document in a local cache. The local cache is synchronised with distributed cache based on the documents version:if it changed the document has to be reloaded from the database. This avoid the serialization/unserialization process of the whole document in the distributed cache.
On Tue, May 27, 2008 at 10:43 AM, Vincent Massol <[email protected]> wrote:
Some more thoughts:
1) Actually we can probably use the google collections api for all our needs. For example it has http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common...
2) I'm not sure the PhantomReference is correct. It would be useful if we wanted to save the AST on disk for example but I don't know if that would win us processing time or not. It may. Otherwise a SoftReference would be enough. The difference is that with PhantomeReference the JVM calls you before the item is reclaimed so you can do something with it before it's too late...
3) If we want to go in this direction we'll need to decide if we want to continue using only the Apache Collections fwk or if it's ok to use both google's and apache's.
4) Do you know of any existing cache framework that we could use directly? (I haven't researched this but you probably have).
Plexus cache api (http://plexus.codehaus.org/plexus-components/plexus-cache/plexus-cache-api/i...) and some implementations. The problem is that the api is not very generic and the way it is designed you need to know the implementation you use to correctly configure the cache to create. But maybe I take it the wrong way and should not try to force the whole XWiki Platform to be able to use any cache component implementation...
Except for the plexus one I did not found a real "framework of cache framework" but I did not search weeks for it...
Thanks -Vincent
On May 27, 2008, at 10:35 AM, Vincent Massol wrote:
Hi Thomas,
I know you're working on the new cache component (btw would be nice if you could send an email with your planned architecture/api so that it can be reviewed - like show the APIs) so I thought I should give you some needs/ideas I have on this topic.
* We need several types of local caches. I can see at least the following types: - a timed cache. I need this for example to cache macros - a cache with a fixed given capacity and expiring the oldest entries (not really sure where we need this right now but it looks common enough) - a cache with a fixed given capacity and expiring the least accessed entries (not really sure where we need this right now but it looks common enough) - a cache with unlimited capacity and bound only by the memory available. The way to implement this is using PhantomReference. Basically it's the JVM that calls back the reference to tell it it needs memory. I was told that the new google collections api have some code that do this (I think FinalizablePhantomReference). This cache is the one I would use to save wiki pages' AST in memory.
Of course we shouldn't implement anything ourselves and we should use existing framework(s) underneath our own API for the Cache API.
WDYT?
Links: * http://www.realjenius.com/node/377 * http://www.javalobby.org/forums/thread.jspa?threadID=16520&messageID=9182240...
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne