What you are trying to do sounds quite cool !
Huh. Well, thanks; coming from an ex-Netscaper ("Netscapee"?) who has, at one time at least, been on the leading edge of cool, I take that as high cred. By the way, to which did you refer: my self-styled "mashup" or the generic read-thru cache plugin idea? I finally wended my way through the maze of run-time indirections to where I could get a reference to the XWiki cache that was not scoped only to the request, and it works fine, even from Velocity, as long as I avoid any chance of that NeedsRefreshException, which I did initially by always getting the object from the cache, with a never-expiring freshness parameter, and optionally calling the method to load it immediately beforehand.
You can either store your cache object in your plugin (but not in the API wrapper which is request specific). An easier way is to store it in the Servlet context.
Yes, I know I can do it in a plugin, which can easily have its own cache with its own rules and its own namespace (in fact, I note that the plugin interface has APIs to whack its cache, and also that many of XWiki's cache keys are pretty short and not terribly unique, so I was careful to put a fairly long hierarchical-style prefix on all my key values); but I just wanted to see if I could do it from within Velocity so that I could do a quick proof-of-concept. And of course I could dispense with plugins and cache parameters entirely if the URL handling within org.dom4j.io.SAXReader.read(String) could be configured to cache responses just like a browser does. Working inside the plugin will allow me to catch the XWikiCacheNeedsRefreshException and refresh the cache, then get it again and return the value. Or, there may be an even easier way to do it, seeing that the OSCache object has some concept of listener objects. Another thing I'd like to do is automatically and pre-emptively preload a cache entry before it expires, to avoid hanging any real-time requests. Also, the presence indicator images, though they have only three or four distinct values, are cached by the URL of the request - for the individual user - so they have to be requested for every user. What I plan to do is have XWiki cache the status and send only the three or four URLs for the image tags to the browser, which will load them at most once per page. To do either this or the above requires that I have some kind of mechanism in XWiki that is more or less autonomous, rather than only in response to a request. But as far as I know, nothing happens in XWiki - including loading the context - until it gets a request, and I don't even know whether a servlet can do anything autonomously, so that will take more investigation. Thanks again... brain[sic]