> -----Original Message-----
> From: David Brown [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 10, 2005 11:41 PM
> To: CF-Talk
> Subject: Server Scope
> 
> A few questions:
> 
> Is it good practice or wise to create an object in the server scope? And
> if so how long does it live? I see in the administrator Memory Variables
> you can set the application and Session time to live, but not server
> scope.

Generally it's only wise to use the server scope on servers (or instances)
you control completely - never trust it on shared servers.  This doesn't
just mean hosting but also internal shared servers (consolidated corporate
application servers for example).  It's just not worth it.

> What I want to do.
> 
> <cfif (not structKeyExists(server, "MyPalAuth")) or
> isdefined("url.Flush")>
> 
> <cflock name="Lock_MyPalAuth" timeout="5" type="EXCLUSIVE">
> 
> <cfobject name="Server.MyPalAuth" component="mycoms.MyPalAuth">
> 
> </cflock>
> 
> </cfif>

Depending on the need for this you may not need the lock - or you may need a
better check.

Your first CFIF checks to see if something exists: but multiple requests may
hit that at the same time.  This means that multiple templates will be
sitting on that lock - waiting for it to free up.

So if you start your server under load your <cfobject> call may occur
multiple times.  To prevent this you'll need to do your check twice (but
only do the URL check the first time):

<cfif (not structKeyExists(server, "MyPalAuth")) or isdefined("url.Flush") >
<cflock name="Lock_MyPalAuth" timeout="5" type="EXCLUSIVE">
<cfif (not structKeyExists(server, "MyPalAuth"))>

        <cfobject name="Server.MyPalAuth" component="mycoms.MyPalAuth">

</cfif>
</cflock>
</cfif>

> I read this from Ben's new Advanced Macromedia ColdFusion MX 7 Application
> Development book. But he used Application scope. I want the object to be
> created once on our intranet and then invoke it when needed in more then
> one application. I could place it in the application scope, but then that
> would mean for each application I would have to recreate the object.

It sound like a perfect use for the Server Scope.

Jim Davis






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206306
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to