Clearing CFFunction "CachedWithin"?

I’ve been using the cachedWithin on some function calls that do some consistent hashing. But, I’m finding that if I change the logic of the hashing, I need to change the name of the function in order to see it get reprocessed. I’m wondering if there is a way to clear the cache used by the cachedWithin settings? I’ve tried “clearing” all the options in the Server/Web admin for cache/performance, but nothing seems to affect it.

I know that once this goes to production, it won’t be an issue; but, during development, it would be nice to be able to clear the cache.

Have you tried using SystemCacheClear()? SystemCacheClear() :: Lucee Documentation

I’ve never used it, but it looks like it allows for functions as one of the caches you can pass to it. I am not aware of anything in the admin UI for clearing function cache.

3 Likes

Ha, literally never seen this function before in my life :smiley: I’ll try it out, thanks!

I am not sure if this is implemented yet, but I think there was an idea of adding the tags attribute so you could then clear by tag (so for example you could clear the cache of all “userProfile” tagged queries and functions) using CacheClear ( see CacheClear() :: Lucee Documentation )
It’s certainly is in cfquery <cfquery> :: Lucee Documentation but I guess not in cffunction. I must pester @micstriit about this.

1 Like

Oh man, there’s a bunch of caching functionality that I’m not familiar with. I’ll dig into this, thanks!

if it’s not in jira, it’s not a bug :slight_smile:

2 Likes

Unfortunately, systemClearCache( "function" ) does not see to help :frowning: It was a good thought, though!

well it should! file a bug

Does it work via the admin? If so, there there’s a cfadmin function to do it

From what I recall, when looking in the admin under caching, it always said 0 next to the Function cache, even when using cachedWithin on the functions. That was one of the first places I looked :smiley:

Hey folks,

Hope all’s well, @bennadel and @Zackster.

Is there any more interest in this issue?

I’m finding that:

SystemCacheClear()

and

SystemCacheClear(cacheName="function");

Don’t work to clear function caches.

“Develop Mode” in the Lucee admin also doesn’t seem to suppress reading from the function cache.

The Lucee admin reads ‘0’ as someone mentioned earlier, even though the function cache is being read and used.

Lucee CFML is lightning fast on my current project and the performance is amazing, mainly due to selective use of cffunction and cacheWithin, however not being able to clear it is very difficult.

It’s got to a silly level where I’m having to append names to functions to escape the cache, using names like myFunction1 and myFunction2 because I can’t clear the cache for myFunction! :sweat_smile:

Screenshot 2022-10-30 at 23.26.01

[Lucee 5.3.9.166]

yeah, looking into the code, pretty sure this doesn’t hit the per application caches, only the current application. this bug is related [LDEV-3388] - Lucee

can you file a bug please?

1 Like

Ok, have filed a bug report, Zack!

(1) You mentioned this works per-application, so I tried these functions but they also don’t seem to affect the app’s function cache either, interestingly:

applicationStop();
structClear(application);
OnApplicationStart();

(2) What’s more weird is that I just noted that I don’t even have a cache defined for Function caching in Lucee Admin.

stopping or starting an application has no effect on a cache, only a restart if you don’t specify a cache

if you don’t define a cache, lucee uses an internal ram cache (i.e. a good old java struct)

(*)

2 Likes

You can also use the cfObjectCache tag to clear the items from the cache

// to clear
<cfobjectcache action="clear" type="function"/>