what do people think of `cachedWithin="instance"` ...
# lucee
z
what do people think of
cachedWithin="instance"
along the lines of
cachedWithin="request"
for functions https://docs.lucee.org/reference/tags/function.html
r
what would be the difference between instance and request?
s
beat me to it lol
z
say you create a object which you stick in the application scope, that's the instance
s
so its just more generic and looks back to the scope to determine lifetime?
z
then if wanna reset the cache, reinstatiate the object
no lifetime for this case (could be too)
r
if we are talking about naming convention, It would seem that if we are sort of following the scope naming like 'request', maybe it would be easier for folks to understand instance caching as being 'application' ? just throwing 2 cents
z
but it could be in your session, your server scopes too?
r
maybe then there could be another cachedwithin type named session?
s
would this be implemented in queries as well?
z
could be, i'm just throwing ideas up
but this isn't about the scope, i can have a cfc which i reuse for different things
a generic cache of users, avis, etc, so I have 6 of them at once
at the moment it's cached keyed by (line of code. function name, hash(args))
s
i like the idea since i wouldn’t need to manage the cache timeout across methods. would there be a way to clear the cache from within the cfc?
r
I like the idea as well, Zack
z
CacheClear(_this_);
or something ?
s
yeah, that would work
z
definately feels to me like a handy tool to have lying around, there are things i'd do more often if there wasn't all the boiler plate required to do this kind of thing
s
so from anywhere in the cfc i can call
CacheClear(_this_);
to clear all the caching and if i wanted to clear the cache of a single function i could do
CacheClear(_this.myfunctionname_);
?
z
something like that, or a
instanceCacheClear
s
ok so from anywhere i could then call
Copy code
instanceCacheClear(myobject,"myfunction") //specfic
instanceCacheClear(myobject) //entire instance
and inside
Copy code
instanceCacheClear(this,"myfunction") //specfic
instanceCacheClear(this) //entire instance
z
inside, no this, maybe only inside
s
meaning inside
Copy code
instanceCacheClear("myfunction") //specfic
instanceCacheClear() //entire instance
?
z
yeah, that's what I'm thinking, when just within the cfc,
instanceCacheClear(myfunction)
could work too?
s
yeah!
z
ok, let me write up a post on dev.lucee.org