Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

In memory structure of object broker

application

-

objectbroker

-

-

typename

-

-

-

objectpool

(structure, keyed by OBJECTID, of content item structures)

-

-

-

aObjects

(manage object pooling by FIFO)

Basic process flow

  1. on fourq.getData() calls
    • check typename.objectpool for UUID
      • if present
        • return struct
      • if not,
        • make dbgateway call
        • check if room in objectpool
        • purge/update aobjects FIFO list as required
        • update objectpool with object struct
        • return struct
      • update cache stats
  2. return object struct to content type call exactly as per original

Essentially update dbgateway calls for CRUD methods in fourq.cfc with calls to object broker. dbgateway would then be responsible for making calls on the Object broker. Update delete and setdata calls to purge objectpool as required.

Reality Check

Currently fourq goes through dbgateway for create, set and delete method calls but not getdata(). Object broker should be an inherent part of the dbgateway componentry. In any event should be easy to get a getdata cache going that ignores underlying data changes through setdata(). Need to update getdata() to go through the dbgateway.

Quick and nasty prototype seems to work well

/fourq/fourq.cfc
	<cffunction name="getData" access="public" output="false" returntype="struct" hint="Get data for a specific objectid and return as a structure, including array properties and typename.">
		<cfargument name="objectid" type="uuid" required="true">
		<cfargument name="dsn" type="string" required="false" default="#application.dsn#">
		<cfargument name="dbowner" type="string" required="false" default="#ucase(application.dbowner)#">
		<cfargument name="bShallow" type="boolean" required="false" default="false" hint="Setting to true filters all longchar property types from record.">
		<cfargument name="bFullArrayProps" type="boolean" required="false" default="false" hint="Setting to true returns array properties as an array of structs instead of an array of strings.">
		<cfargument name="bUseInstanceCache" type="boolean" required="false" default="true" hint="setting to use instance cache if one exists">
		
		<cfset var stobj=structnew()>
		<cfset var tablename=getTablename()>
		<cfset var aprops="">
		<cfset var sqlSelect="">
		<cfset var i=0>
		<cfset var qgetData="">
		<cfset var key="">
		<cfset var qArrayData="">
		<cfset var aTmp=arraynew(1)>
		<cfset var stArrayProp=structnew()>
		<cfset var col=0>
		<cfset var j=0>
		
		<cfparam name="instance.stobj.typename" default="#tablename#">

		<cfif isdefined("instance.bgetdata") AND instance.bgetdata EQ arguments.objectid AND arguments.bUseInstanceCache>
			<!--- get local instance cache --->
			<cfset stObj = instance.stobj>
			<cftrace type="information" category="coapi" var="stobj.typename" text="getData() used instance cache.">
			
		<!--- todo: prototype object manager --->
		<cfelseif structkeyexists(application.objectbroker, instance.stobj.typename) AND structkeyexists(application.objectbroker[instance.stobj.typename], arguments.objectid)>
			<cfset stObj = application.objectbroker[instance.stobj.typename][arguments.objectid]>
			<cfset instance.bgetData = arguments.objectid>
			<cftrace type="information" category="coapi" var="stobj.typename" text="getData() used objectpool cache.">
			
		<cfelse>
			<!--- build a local instance cache --->
			<cfinclude template="_fourq/getData.cfm">
			<cfset instance.stobj = stobj>
			<cfset instance.bgetData = arguments.objectid>
			<cftrace type="information" category="coapi" var="stobj.typename" text="getData() used database.">
			
			<!--- todo: prototype object manager (populate pool) --->
			<cfif structkeyexists(application.objectbroker, instance.stobj.typename)>
				<cfset application.objectbroker[instance.stobj.typename][stobj.objectid]=duplicate(stobj)>
			</cfif>
		</cfif>
		
		<cfreturn stObj>
	</cffunction>
/config/_serverspecificvars.cfm
// todo: prototype object manager (config)
application.objectbroker=structNew();
application.objectbroker.dmnavigation=structnew();
application.objectbroker.dmhtml=structnew();
application.objectbroker.dmnews=structnew();
application.objectbroker.dmimage=structnew();
application.objectbroker.dmfile=structnew();
application.objectbroker.ruleHandpicked=structnew();
  • No labels