Tim:

The only issue I could see is if MACR decides later to radically alter the
way it renders the string-based representation of a function.  I'm sure it's
not "supported" to rely on that construct.  That said, you're probably safe
(unless you use that same key to persist the data).

It also could make it a PITA if you want to go back and change the API to
have different method names (because you'll need to remember to change the
references too).  That's not a show-stopper, however.

Also, if you're using this for the keys to a struct you shouldn't need to
worry about going through the hassle of the keyprefix or the hash() -- which
just add overhead.

I'm very curious to know, though, why you want it to be based on the name of
the function rather than just a "normal" key.







> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Tim Blair
> Sent: Tuesday, August 19, 2003 10:50 AM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Uniquely identifying a function
>
>
> Evening,
>
> I'm in the process of creating an application, part of which is a series
> of CFCs which perform and cache data, allowing quick retrieval on the
> next call.  This is done by passing a reference to a function to a
> method of a CFC which then runs the function after doing some other
> processing and returns the data.
>
> Now I want to be able to cache the data generated.  The generated data
> will be plain text and so I'm just planning on storing it (keyed on
> something that uniquely identifies the funciton used) within an
> structure as an instance variable in the CFC.
>
> So basically, I need a way to generate a structure key based on a
> reference to a function.  The way I've come up with is simply a hash of
> the toString of the function, prefixed with an arbitrary string so the
> variable name is valid, as so:
>
> <cfset this.KEYPREFIX = "i">
> <cfset key = this.KEYPREFIX & hash(myFuncRef.toString())>
>
> Which results in a key of "i8CF622BA70E703A796DB0FD8AC8ABFA8" -- a valid
> variable name and unique to the function called.
>
> The myFuncRef.toString() returns an output similar to
> "[EMAIL PROTECTED]" which is basically the
> associated compiled java class.  AFAIK this uniquely identifies the
> function being used and means I don't have to manually associate an ID
> with each function.  The hash() + the string prefix call makes sure that
> any invalid chars get removed and the chance of two hash() calls
> returning the same value is supposedly around 1 in 2^64 so it should be
> safe there...
>
> Basically, does anyone see any issue with doing it this way?
>
> Tim.
>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to