Hello,

Patrick Lightbody wrote:
We could probably write some velocity-oscache integration. Francois, is this
possible?
Yes it's possible and I think someone may have had something working a while ago but I don't know what ever happened ...

To cache whole JSP pages OSCache uses a servlet filter. Of course, this should work equally as well with Velocity. However, by setting a couple of Velocity properties, templates will be cached for some specified amount of time (for the entire application). This isn't quite the same as it's caching a parsed version of the template, not the output. It would also be possible to cache template output within the Velocity servlet as it is written out which would have the same effect as a servlet filter.

To cache sections of a template, a #cache Velocity directive could be implemented which functions in a similar manner to the <cache:cache> JSP tag. As named paramaters aren't supported in Velocity, parameters would have to be positional or multiple name=value pairs could be specified. Unlike macros, directives can support a variable number of parameters. For example (adapted from the OSCache tag doc):
#cache()
... some content ...
#end

Specify a key and session:
#cache("key=foobar", "scope=session")
... some content ...
#end

An optimization could be if there's only one parameter or the first parameter is not a name=value pair, assume it's the key:
#cache("foobar")
... some content ...
#end

Specifying dynamic values to parameters is easy:
#cache("key=$product.Id", "time=1800", "refresh=$needRefresh")
... some content ...
#end

Someone has written a patch to Velocity adding map support. This will hopefully be incorporated into Velocity 1.4. The syntax might be something like:
#cache( { key : $product.Id, time : 1800, refresh : $needRefresh } )

The best references I'm aware of for writing Velocity directives are the Velocity directives themselves and DVSL, a Velocity based XSLT (http://jakarta.apache.org/velocity/dvsl/index.html).

-Bill

-Pat

----- Original Message -----
From: "Heng Sin Low" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 13, 2003 4:41 PM
Subject: RE: Re: [OS-webwork] Webwork 2.0



I was under the impression that you can only use oscache with jsp but we
plan

to use velocity only.

Regards,
Low


-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to