Cache Purging

I'm using cacheBox and event caching, and I'm trying to purge an event
from the cache. I'm using the new onRequestCapture intercept point, to
create user specific cached events.

I'm wanting to (when a user performs a certain action), purge the
cached event for that particular user.

I'm wanting to do this (ideally) via an url argument: i.e /basket/
viewbasket?purge=true. The issue is (obviously), that once I append an
url argument, cachbox thinks the event (due to the argument) is
different, so I'm not actually clearing the /basket/viewbasket event,
I'm purging the /basket/viewbasket?purge=true (!).

I tried fwCache argument (as I presumed that would be ignored), but it
doesn't seem to work. I'm thinking that cachebox doesn't recognise
this.

I've tried something ugly like:

var purge = arguments.event.getValue("purge",false);
    if (purge) {
       rc.ckey = createUUID(); // create a unique rc variable so this
event gets "re-cached"
       StructDelete(url,"purge");
       StructDelete(rc,"purge");
    }

But that doesn't seem to work either.

Any ideas anyone?

Right - looking at the source, fwCache should do what I want, so I
suspect this is a bug.

/view/basket and /view/basket?fwCache=true are seen as different
events as fwCache is not removed from the Request Collection, and
therefore the two URLs have different cache keys.

Really, fwCache should be removed so the two urls have the same key.

Perhaps someone could confirm this?

Thanks,

Tom.

The fwCache flag tells the framework, hey, don't cache this event that is happening right now, useful for sending a message back to the event, but not caching the message, etc, but it does not purge the event from cache, to clear events from cache you can use

getColdBoxOCM("template").clearAllEvents();
//Trigger to purge all Events
getColdBoxOCM("template").clearAllEvents();

//Trigger to purge all events synchronously
getColdboxOCM("template").clearAllEvents(async=false);

//Purge all events from the blog handler
getColdbocxOCM("template").clearEvent('blog');

//Purge all permutations of the blog.dspBlog event
getColdbocxOCM("template").clearEvent('blog.dspBlog');

//Purge the blog.dspBlog event with entry of 12345
getColdbocxOCM("template").clearEvent('blog.dspBlog','id=12345');

//Purge the all events in a list called eventList with a query string data in the querystringList
getColdbocxOCM("template").clearEventMulti(eventlist,querystringList);

For more information visit http://wiki.coldbox.org/wiki/ColdboxCache.cfm

Hope that helps,

Curt Gratz
Computer Know How

Kurt,

I don't think that's correct.

if ( context.valueExists("fwCache") ){
  // Clear the key from the cache
  instance.templateCache.clearKey( eventCacheKey );
            return;
}

That's in RequestService.cfc.

Looks to me like it's supposed to purge the cache for that key.

All of the functions you listed would clear the cache for ALL events, not
just the ones with the request collection objects that make them session
unique.

Furthermore, in the docs link you kindly provided, it states:

Cached Event Life cycle
2. URL action fwCache is verified, if it exists, incoming event is purged
from cache.

Tom.

Yes, but the I am pretty sure fwCache is part of the hashed key, IE, its own permutation of the event, so yes, that event is purged from the cache.

Also, any of these are used to granularity control purging events from cache at different levels, not "All" Events

//Purge all events from the blog handler
getColdbocxOCM("template").clearEvent('blog');

//Purge all permutations of the blog.dspBlog event
getColdbocxOCM("template").clearEvent('blog.dspBlog');

//Purge the blog.dspBlog event with entry of 12345
getColdbocxOCM("template").clearEvent('blog.dspBlog','id=12345');

//Purge the all events in a list called eventList with a query string data in the querystringList getColdbocxOCM("template").clearEventMulti(eventlist,querystringList);

Curt

Hi Kurt,

Yes - that's exactly the problem, fwCache is part of the hashed key. I'm not
convinced it should be, and I think it's a bug.

If the idea of fwCache is merely to prevent the event from being cached,
then all you'd need to do in RequestContext is:
if ( context.valueExists("fwCache") ){
            return;
}

That would have exactly the same effect; you wouldn't need to remove the key
from the cache as your ending the function before setEventCacheableEntry is
triggered later down in the code. Also, it wouldn't make sense to cache the
event, then delete the event from the cache - not exactly efficient when you
can just not cache the event in the first place!

Also, I'm pretty sure that, for example,
getColdboxOCM("template").clearEvent('blog.dspBlog') will clear all cached
blog.dspBlog events - NOT just my session specific version of blog.dspBlog
which I've created using the onRequestCapture intercept point (by injecting
my cftoken into the request collection).

Tom.

Sorry - CURT :wink:

Ha, no problem Tom.

With this

getColdbocxOCM("template").clearEvent('blog.dspBlog','id=12345');

if you make the second paramater there a querystring equal to all your items in the request collection for the event you which to purge, that will clear that individual perumation of the event

Curt