Inline below

Sami Hoda said the following on 08/04/2010 12:01 PM:
> When I build the cache, I'm assuming it will cache the first user and
> present the same info for all users unless I use the criteria
> parameter like so: <cache alias="userCache" criteria="$
> {event.userID}">. Is that correct?
>   
Yes, but you can just shorten it to:

<cache alias="userCache" criteria="userID">

As criteria takes a list of event names or you can use the M2EL syntax
if you have a complicated thing like:

<cache alias="userCache" criteria="id=${event.userId.otherBean.id}">

Which basically translates to:

event.getArg("userId").getOtherBean().getId()

> And so my next question is on how flexible criteria is. We won't have
> userID as an event arg with every request. Typically that stuff is
> stored upon login in the session. However, another assumption of mine
> is that criteria is only tied to the event scope (and form/url by
> extension), meaning I can't place criteria="${session.userID}"...
>   
We only support "event" and "properties" scopes.  The best way to
integrate this is to have a plugin that pulls in the info you need from
the session into the event. For us, this is an Authentication bean so
everything is encapsulated nicely into an auth event arg in which we can
make method calls.  You might consider this or doing what's below...
> And then, my next issue is that I don't want criteria accessing
> session scope directly, but using my sessionFacade for best practices.
> So ideally, I'd like for criteria to look like this:  criteria="$
> {model.sessionFacade.getUserID()}"...
>   
If you are using ColdSpring, you can use the beansToProperties parameter
to place a reference of your SessionFacade into the properties.  Or you
could manually place a reference to your SessionFacade there. So this is
possible:

<cache alias="userCache"
criteria="userId=${properties.sessionFacade.userId}">

Each dot place assumes either a struct key or a method that starts with
"get" so that translates to:

getProperty("sessionFacade").getUserId()

If you want to make a method call to a method that doesn't start with
"get", then you can't use the shorthand notation:

${properties.sessionFacade.logout()}

Which translates to:

getProperty("sessionFacade").logout()

HTH,
.pjf

-- 
You received this message because you are subscribed to Mach-II for CFML list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en

***New URLs as of April 29th, 2010***
SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/

Reply via email to