From: <jfi...@us...> - 2003-01-09 01:53:42
|
Update of /cvsroot/modus/org/bacfug/modus/caching In directory sc8-pr-cvs1:/tmp/cvs-serv5475/caching Modified Files: basecache.cfc serverscopecache.cfc Log Message: Whoops, these were the old files - pardon my CVS skills. The new files are now there. Index: basecache.cfc =================================================================== RCS file: /cvsroot/modus/org/bacfug/modus/caching/basecache.cfc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** basecache.cfc 29 Oct 2002 00:04:58 -0000 1.2 --- basecache.cfc 9 Jan 2003 01:53:39 -0000 1.3 *************** *** 8,31 **** <cfreturn this> </cffunction> ! <!--- is the cache primed ---> ! <cffunction name="isCacheInitialized" access="package" output="no" returnType="boolean" hint="Returns a boolean for whether the cache is initialized"> <cfthrow message="isCacheInitialized() not implemented in #getMetaData(this).name#"> </cffunction> - <!--- initialize the cache ---> <cffunction name="cacheInit" access="package" output="no" returnType="void" hint="Initializes the cache"> <cfthrow message="cacheInit() not implemented in #getMetaData(this).name#"> </cffunction> ! <!--- is a particular object instance in the cache? ---> ! <cffunction name="isObjectCached" access="package" output="no" returnType="boolean" hint="Returns a boolean for whether a particular object (Based on ID) is cached"> <cfthrow message="isObjectCached not implemented in #getMetaData(this).name#"> </cffunction> ! ! <!--- put an object in the cache ---> ! <cffunction name="putObject" access="package" output="no" returnType="void" hint="Put a contentObject instance into the cache"> <cfthrow message="putObject not implemented in #getMetaData(this).name#"> </cffunction> ! ! <!--- get an object from the cache ---> ! <cffunction name="getObject" access="package" output="no" returnType="org.bacfug.modus.baseContentObject" hint="get an object instance from the cache"> <cfthrow message="getObject not implemented in #getMetaData(this).name#"> </cffunction> --- 8,24 ---- <cfreturn this> </cffunction> ! <cffunction name="isCacheInitialized" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether the cache is initialized"> <cfthrow message="isCacheInitialized() not implemented in #getMetaData(this).name#"> </cffunction> <cffunction name="cacheInit" access="package" output="no" returnType="void" hint="Initializes the cache"> <cfthrow message="cacheInit() not implemented in #getMetaData(this).name#"> </cffunction> ! <cffunction name="isObjectCached" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether a particular object (Based on ID) is cached"> <cfthrow message="isObjectCached not implemented in #getMetaData(this).name#"> </cffunction> ! <cffunction name="putObject" access="public" output="no" returnType="void" hint="Put a contentObject instance into the cache"> <cfthrow message="putObject not implemented in #getMetaData(this).name#"> </cffunction> ! <cffunction name="getObject" access="public" output="no" returnType="org.bacfug.modus.baseContentObject" hint="get an object instance from the cache"> <cfthrow message="getObject not implemented in #getMetaData(this).name#"> </cffunction> Index: serverscopecache.cfc =================================================================== RCS file: /cvsroot/modus/org/bacfug/modus/caching/serverscopecache.cfc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** serverscopecache.cfc 18 Nov 2002 20:29:16 -0000 1.2 --- serverscopecache.cfc 9 Jan 2003 01:53:39 -0000 1.3 *************** *** 1,42 **** <cfcomponent hint="Uses the server scope for caching" extends="org.bacfug.modus.caching.baseCache"> - <!--- is the cache primed ---> - <cffunction name="isCacheInitialized" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether the cache is initialized"> - <cfreturn structKeyExists(server,"modus") AND structKeyExists(server.modus,"contentObjectCache") AND structKeyExists(server.modus.contentObjectCache,"objectInstances")> - </cffunction> - <!--- initialize the cache ---> - <cffunction name="cacheInit" access="public" output="no" returnType="void" hint="Initializes the in-memory cache"> - <cfparam name="server.modus" default="#structNew()#"> - <cfparam name="server.modus.contentObjectCache" default="#structNew()#"> - <cfparam name="server.modus.contentObjectCache.objectInstances" default="#structNew()#"> - <cfparam name="server.modus.contentObjectCache.objectTypes" default="#structNew()#"> - - <!--- <cfscript> - server.modus.contentObjectCache = structNew(); - server.modus.contentObjectCache.objectInstances = structNew(); - server.modus.contentObjectCache.objectTypes = structNew(); - </cfscript> ---> - </cffunction> ! <!--- is a particular object instance in the cache? ---> ! <cffunction name="isObjectCached" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether a particular object (Based on ID) is cached"> ! <cfargument name="id" required="yes" type="string"> ! <cfreturn structKeyExists(server.modus.contentObjectCache.objectInstances,arguments.id)> ! </cffunction> ! ! <!--- put an object in the cache ---> ! <cffunction name="putObject" access="public" output="no" returnType="void" hint="Put a contentObject instance into the cache"> ! <cfargument name="contentObject" required="yes" type="org.bacfug.modus.baseContentObject"> <cfscript> ! server.modus.contentObjectCache.objectInstances[arguments.contentObject.getID()] = arguments.contentObject.makeClone(); ! </cfscript> ! </cffunction> ! ! <!--- get an object from the cache ---> ! <cffunction name="getObject" access="public" output="no" returnType="org.bacfug.modus.baseContentObject" hint="get an object instance from the cache"> ! <cfargument name="id" required="yes" type="string"> ! <cfif NOT isObjectCached(arguments.id)> ! <cfthrow type="modus.badCacheRequest" message="Object does not exist in the cache" detail="The contentObject with ID ""#arguments.id#"" does not exist in the cache. You may not request an object that is not cached."> ! </cfif> ! <cfreturn server.modus.contentObjectCache.objectInstances[arguments.id]> ! </cffunction> </cfcomponent> --- 1,103 ---- <cfcomponent hint="Uses the server scope for caching" extends="org.bacfug.modus.caching.baseCache"> ! <cffunction name="cacheInit" access="public" output="no" returnType="void" hint="Initializes the in-memory cache"> ! <cflock scope="SERVER" timeout="10" type="EXCLUSIVE"> ! <cfparam name="server._modus" default="#structNew()#"> <cfscript> ! server._modus.core.cache.objectInstances = structNew(); ! server._modus.core.cache.objectTypes = structNew(); ! server._modus.core.cache.collections = structNew(); ! </cfscript> ! </cflock> ! </cffunction> ! <cffunction name="isCacheInitialized" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether the cache is initialized"> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn structKeyExists(server,"modus") AND structKeyExists(server._modus,"contentObjectCache") AND structKeyExists(server._modus.core.cache,"objectInstances")> ! </cflock> ! </cffunction> ! <cffunction name="isObjectCached" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether a particular object (Based on ID) is cached"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" required="Yes" type="string"> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn structKeyExists(server._modus.core.cache.objectInstances,arguments.type & arguments.id)> ! </cflock> ! </cffunction> ! <cffunction name="getObject" access="public" output="no" returnType="struct" hint="get an object instance from the cache"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" required="Yes" type="string"> ! <cfif NOT isObjectCached(arguments.id, arguments.type)> ! <cfthrow type="modus.badCacheRequest" message="Object does not exist in the cache" detail="The contentObject with ID ""#arguments.id#"" does not exist in the cache. You may not request an object that is not cached."> ! </cfif> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn duplicate(server._modus.core.cache.objectInstances[arguments.type & arguments.id])> ! </cflock> ! </cffunction> ! <cffunction name="getObjectRef" access="public" output="no" returnType="struct" hint="get a reference to an object instance in the cache"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" required="Yes" type="string"> ! <cfif NOT isObjectCached(arguments.id, arguments.type)> ! <cfthrow type="modus.badCacheRequest" message="Object does not exist in the cache" detail="The contentObject with ID ""#arguments.id#"" does not exist in the cache. You may not request an object that is not cached."> ! </cfif> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn server._modus.core.cache.objectInstances[arguments.type & arguments.id]> ! </cflock> ! </cffunction> ! <cffunction name="putObject" access="public" output="no" returnType="void" hint="Put a contentObject instance into the cache"> ! <cfargument name="contentObject" required="yes" type="struct"> ! <cfargument name="type" required="Yes" type="string"> ! <cflock scope="SERVER" timeout="10" type="EXCLUSIVE"> ! <cfscript> ! server._modus.core.cache.objectInstances[arguments.type & arguments.contentObject.id] = duplicate(arguments.contentObject); ! </cfscript> ! </cflock> ! </cffunction> ! <cffunction name="flushObject" access="public" output="no" returnType="void" hint="remove an object instance from the cache"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" type="string" required="Yes"> ! <!--- Clear object from cache - no need to check if it exists with structClear function ---> ! <cfset structDelete(server._modus.core.cache.objectInstances,arguments.type & arguments.id)> ! </cffunction> ! <cffunction name="isCollectionCached" access="public" output="no" returnType="boolean" hint="Returns a boolean for whether a particular collection (Based on ID) is cached"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" type="string" required="Yes"> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn structKeyExists(server._modus.core.cache.collections, arguments.type & arguments.id)> ! </cflock> ! </cffunction> ! <cffunction name="getCollection" access="public" returntype="array" output="no" hint="get a collection of collections instance from the cache"> ! <cfargument name="id" type="string" required="yes"> ! <cfargument name="type" type="string" required="Yes"> ! <cfif NOT isCollectionCached(arguments.id, arguments.type)> ! <cfthrow type="modus.badCacheRequest" message="Collection does not exist in the cache" detail="The collection with ID ""#arguments.id#"" does not exist in the cache. You may not request a collection that is not cached."> ! </cfif> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn duplicate(server._modus.core.cache.collections[arguments.type & arguments.id])> ! </cflock> ! </cffunction> ! <cffunction name="getCollectionRef" access="public" output="no" returnType="array" hint="get a reference to a collection instance in the cache"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" type="string" required="Yes"> ! <cfif NOT isCollectionCached(arguments.id, arguments.type)> ! <cfthrow type="modus.badCacheRequest" message="Collection does not exist in the cache" detail="The contentCollection with ID ""#arguments.id#"" does not exist in the cache. You may not request an collection that is not cached."> ! </cfif> ! <cflock scope="SERVER" timeout="10" type="READONLY"> ! <cfreturn server._modus.core.cache.collections[arguments.type & arguments.id]> ! </cflock> ! </cffunction> ! <cffunction name="putCollection" access="public" output="no" returnType="void" hint="Put a collection of collections instance into the cache"> ! <cfargument name="id" type="string" required="Yes"> ! <cfargument name="collection" type="array" required="yes"> ! <cfargument name="type" type="string" required="Yes"> ! <cflock scope="SERVER" timeout="10" type="EXCLUSIVE"> ! <cfscript> ! server._modus.core.cache.collections[arguments.type & arguments.id] = duplicate(arguments.collection); ! </cfscript> ! </cflock> ! </cffunction> ! <cffunction name="flushCollection" access="public" output="no" returnType="void" hint="remove a collection from the cache"> ! <cfargument name="id" required="yes" type="string"> ! <cfargument name="type" type="string" required="Yes"> ! <!--- Clear object from cache - no need to check if it exists with structClear function ---> ! <cfset structDelete(server._modus.core.cache.collections,arguments.type & arguments.id)> ! </cffunction> </cfcomponent> |