Changeset 1699
- Timestamp:
- 08/14/08 15:09:06 (5 months ago)
- Files:
-
- coldbox/trunk/system/cache/cacheManager.cfc (modified) (14 diffs)
- coldbox/trunk/system/cache/policies/AabstractEvictionPolicy.cfc (deleted)
- coldbox/trunk/system/cache/policies/AbstractEvictionPolicy.cfc (modified) (1 diff)
- coldbox/trunk/system/cache/policies/FIFO.cfc (added)
- coldbox/trunk/system/cache/policies/LFU.cfc (modified) (1 diff)
- coldbox/trunk/system/cache/policies/LRU.cfc (modified) (1 diff)
- coldbox/trunk/system/config/settings.xml (modified) (1 diff)
- coldbox/trunk/testing/tests/cases/cache/policies/FIFOTest.cfc (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
coldbox/trunk/system/cache/cacheManager.cfc
r1695 r1699 28 28 <cfscript> 29 29 /* Set Controller Injection */ 30 setController( arguments.controller );30 instance.controller = arguments.controller; 31 31 /* Lock Name */ 32 instance.lockName = getController().getAppHash() & "_OCM_OPERATION";32 instance.lockName = instance.controller.getAppHash() & "_OCM_OPERATION"; 33 33 /* Runtime Java object */ 34 34 instance.javaRuntime = CreateObject("java", "java.lang.Runtime"); … … 51 51 <cfargument name="cacheConfigBean" type="coldbox.system.beans.cacheConfigBean" required="true" hint="The configuration object"> 52 52 <!--- ************************************************************* ---> 53 <cfscript> 53 <cfscript> 54 var oEvictionPolicy = 0; 55 54 56 //set the config bean 55 57 setCacheConfigBean(arguments.cacheConfigBean); 56 58 //Reset the statistics. 57 59 getCacheStats().clearStats(); 60 58 61 //Setup the eviction Policy to use 59 setEvictionPolicy( CreateObject("component","coldbox.system.cache.policies.#getCacheConfigBean().getCacheEvictionPolicy()#").init(this) ); 62 try{ 63 oEvictionPolicy = CreateObject("component","coldbox.system.cache.policies.#getCacheConfigBean().getCacheEvictionPolicy()#").init(this); 64 } 65 Catch(Any e){ 66 getUtil().throwit('Error creating eviction policy','Error creating the eviction policy object: #e.message# #e.detail#','cacheManager.EvictionPolicyCreationException'); 67 } 68 /* Save the Policy */ 69 instance.evictionPolicy = oEvictionPolicy; 60 70 </cfscript> 61 71 </cffunction> … … 187 197 <cfif ccBean.getCacheFreeMemoryPercentageThreshold() neq 0 and isJVMSafe eq false> 188 198 <!--- Evict Using Policy ---> 189 <cfset getEvictionPolicy().execute()>199 <cfset instance.evictionPolicy.execute()> 190 200 <!--- Do another Check, just in case ---> 191 201 <cfset isJVMSafe = ThresholdChecks()> … … 194 204 <cfif ccBean.getCacheMaxObjects() neq 0 and getSize() gte ccBean.getCacheMaxObjects()> 195 205 <!--- Evict Using Policy ---> 196 <cfset getEvictionPolicy().execute()>206 <cfset instance.evictionPolicy.execute()> 197 207 </cfif> 198 208 … … 216 226 217 227 <!--- Only execute once the framework has been initialized ---> 218 <cfif getController().getColdboxInitiated()>228 <cfif instance.controller.getColdboxInitiated()> 219 229 <!--- InterceptMetadata ---> 220 230 <cfset interceptMetadata.cacheObjectKey = arguments.objectKey> … … 222 232 <cfset interceptMetadata.cacheObjectLastAccessTimeout = arguments.LastAccessTimeout> 223 233 <!--- Execute afterCacheElementInsert Interception ---> 224 <cfset getController().getInterceptorService().processState("afterCacheElementInsert",interceptMetadata)>234 <cfset instance.controller.getInterceptorService().processState("afterCacheElementInsert",interceptMetadata)> 225 235 </cfif> 226 236 <!--- Return True ---> … … 250 260 <cfset interceptMetadata.cacheObjectKey = arguments.objectKey> 251 261 <!--- Execute afterCacheElementInsert Interception ---> 252 <cfset getController().getInterceptorService().processState("afterCacheElementRemoved",interceptMetadata)>262 <cfset instance.controller.getInterceptorService().processState("afterCacheElementRemoved",interceptMetadata)> 253 263 </cfif> 254 264 … … 297 307 <!--- ************************************************************* ---> 298 308 <cfscript> 299 var cacheKey = getController().getHandlerService().EVENT_CACHEKEY_PREFIX & arguments.eventsnippet;309 var cacheKey = instance.controller.getHandlerService().EVENT_CACHEKEY_PREFIX & arguments.eventsnippet; 300 310 301 311 //Check if we are purging with query string … … 315 325 <!--- ************************************************************* ---> 316 326 <cfscript> 317 var cacheKey = getController().getHandlerService().EVENT_CACHEKEY_PREFIX;327 var cacheKey = instance.controller.getHandlerService().EVENT_CACHEKEY_PREFIX; 318 328 319 329 /* Clear All Events */ … … 342 352 <!--- ************************************************************* ---> 343 353 <cfscript> 344 var cacheKey = getController().getPlugin("renderer").VIEW_CACHEKEY_PREFIX;354 var cacheKey = instance.controller.getPlugin("renderer").VIEW_CACHEKEY_PREFIX; 345 355 346 356 /* Clear All the views */ … … 484 494 485 495 <!--- Get The Cache Item Types ---> 486 <cffunction name="getItemTypes" access="public" output="false" returntype="struct" hint="Get the item types of the cache. ">496 <cffunction name="getItemTypes" access="public" output="false" returntype="struct" hint="Get the item types of the cache. These are calculated according to internal coldbox entry prefixes"> 487 497 <cfscript> 488 498 var x = 1; … … 536 546 537 547 <!--- The cache Config Bean ---> 538 <cffunction name="setCacheConfigBean" access="public" returntype="void" output="false" hint="Set the cache configuration bean.">548 <cffunction name="setCacheConfigBean" access="public" returntype="void" output="false" hint="Set & Override the cache configuration bean. You can use this to programmatically alter the cache."> 539 549 <cfargument name="CacheConfigBean" type="coldbox.system.beans.cacheConfigBean" required="true"> 540 550 <cfset instance.CacheConfigBean = arguments.CacheConfigBean> … … 549 559 </cffunction> 550 560 551 <!--- Controller --->552 <cffunction name="getcontroller" access="public" output="false" returntype="any" hint="Get ColdBox controller">553 <cfreturn instance.controller/>554 </cffunction>555 <cffunction name="setcontroller" access="public" output="false" returntype="void" hint="Set ColdBox controller">556 <cfargument name="controller" type="any" required="true"/>557 <cfset instance.controller = arguments.controller/>558 </cffunction>559 560 561 <!--- Lock Name ---> 561 562 <cffunction name="getlockName" access="public" output="false" returntype="string" hint="Get the lockName used for cache operations"> … … 570 571 <!--- Get the Pool Metadata ---> 571 572 <cffunction name="getpool_metadata" access="public" returntype="struct" output="false" hint="Get the pool's metadata structure"> 572 <cfreturn getObjectPool().getpool_metadata()> 573 </cffunction> 574 573 <cfreturn duplicate(getObjectPool().getpool_metadata())> 574 </cffunction> 575 576 <!--- Set The Eviction Policy ---> 577 <cffunction name="setevictionPolicy" access="private" returntype="void" output="false" hint="You can now override the set eviction policy by programmatically sending it in."> 578 <cfargument name="evictionPolicy" type="coldbox.system.cache.policies.AbstractEvictionPolicy" required="true"> 579 <cfset instance.evictionPolicy = arguments.evictionPolicy> 580 </cffunction> 581 575 582 <!------------------------------------------- PRIVATE -------------------------------------------> 576 577 <!--- Get Set the set eviction Policy ---> 578 <cffunction name="getevictionPolicy" access="private" returntype="coldbox.system.cache.policies.abstractEvictionPolicy" output="false"> 579 <cfreturn instance.evictionPolicy> 580 </cffunction> 581 <cffunction name="setevictionPolicy" access="private" returntype="void" output="false"> 582 <cfargument name="evictionPolicy" type="coldbox.system.cache.policies.abstractEvictionPolicy" required="true"> 583 <cfset instance.evictionPolicy = arguments.evictionPolicy> 584 </cffunction> 585 583 586 584 <!--- Initialize our object cache pool ---> 587 585 <cffunction name="initPool" access="private" output="false" returntype="void" hint="Initialize and set the internal object Pool"> coldbox/trunk/system/cache/policies/AbstractEvictionPolicy.cfc
r1698 r1699 8 8 Date : 11/14/2007 9 9 Description : 10 This is an abstractEviction Policy object.10 This is an AbstractEviction Policy object. 11 11 -----------------------------------------------------------------------> 12 <cfcomponent name=" abstractEvictionPolicy" hint="An abstract cache eviction policy" output="false">12 <cfcomponent name="AbstractEvictionPolicy" hint="An abstract cache eviction policy" output="false"> 13 13 14 14 <!------------------------------------------- CONSTRUCTOR -------------------------------------------> coldbox/trunk/system/cache/policies/LFU.cfc
r1533 r1699 8 8 Date : 11/14/2007 9 9 Description : 10 This is an abstractEviction Policy object.10 This is an AbstractEviction Policy object. 11 11 -----------------------------------------------------------------------> 12 12 <cfcomponent name="LFU" 13 13 output="false" 14 14 hint="LFU Eviction Policy Command" 15 extends="coldbox.system.cache.policies. abstractEvictionPolicy">15 extends="coldbox.system.cache.policies.AbstractEvictionPolicy"> 16 16 17 17 <!------------------------------------------- CONSTRUCTOR -------------------------------------------> coldbox/trunk/system/cache/policies/LRU.cfc
r1607 r1699 8 8 Date : 11/14/2007 9 9 Description : 10 This is an abstractEviction Policy object.10 This is an AbstractEviction Policy object. 11 11 -----------------------------------------------------------------------> 12 12 <cfcomponent name="LRU" 13 13 output="false" 14 14 hint="LFU Eviction Policy Command" 15 extends="coldbox.system.cache.policies. abstractEvictionPolicy">15 extends="coldbox.system.cache.policies.AbstractEvictionPolicy"> 16 16 17 17 <!------------------------------------------- CONSTRUCTOR -------------------------------------------> coldbox/trunk/system/config/settings.xml
r1646 r1699 47 47 <!--ColdBox Cache Parameter: Whether reaping with default last access timeouts --> 48 48 <Setting name="CacheUseLastAccessTimeouts" value="true"/> 49 <!--ColdBox Cache Parameter: The default eviction policy (LFU or LRU ) -->49 <!--ColdBox Cache Parameter: The default eviction policy (LFU or LRU or FIFO) --> 50 50 <Setting name="CacheEvictionPolicy" value="LRU"/> 51 51 <!-- Debugger settings -->
