Changeset 1699

Show
Ignore:
Timestamp:
08/14/08 15:09:06 (5 months ago)
Author:
lmajano
Message:

Finizhed FIFO eviction policy

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • coldbox/trunk/system/cache/cacheManager.cfc

    r1695 r1699  
    2828                <cfscript> 
    2929                        /* Set Controller Injection */ 
    30                         setController( arguments.controller )
     30                        instance.controller = arguments.controller
    3131                        /* Lock Name */ 
    32                         instance.lockName = getController().getAppHash() & "_OCM_OPERATION"; 
     32                        instance.lockName = instance.controller.getAppHash() & "_OCM_OPERATION"; 
    3333                        /* Runtime Java object */ 
    3434                        instance.javaRuntime = CreateObject("java", "java.lang.Runtime"); 
     
    5151                <cfargument name="cacheConfigBean" type="coldbox.system.beans.cacheConfigBean" required="true" hint="The configuration object"> 
    5252                <!--- ************************************************************* ---> 
    53                 <cfscript>                       
     53                <cfscript>               
     54                        var oEvictionPolicy = 0; 
     55                                 
    5456                        //set the config bean 
    5557                        setCacheConfigBean(arguments.cacheConfigBean); 
    5658                        //Reset the statistics. 
    5759                        getCacheStats().clearStats(); 
     60                         
    5861                        //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; 
    6070                </cfscript> 
    6171        </cffunction> 
     
    187197                <cfif ccBean.getCacheFreeMemoryPercentageThreshold() neq 0 and isJVMSafe eq false> 
    188198                        <!--- Evict Using Policy ---> 
    189                         <cfset getEvictionPolicy().execute()> 
     199                        <cfset instance.evictionPolicy.execute()> 
    190200                        <!--- Do another Check, just in case ---> 
    191201                        <cfset isJVMSafe = ThresholdChecks()> 
     
    194204                <cfif ccBean.getCacheMaxObjects() neq 0 and getSize() gte ccBean.getCacheMaxObjects()> 
    195205                        <!--- Evict Using Policy ---> 
    196                         <cfset getEvictionPolicy().execute()> 
     206                        <cfset instance.evictionPolicy.execute()> 
    197207                </cfif> 
    198208                 
     
    216226                         
    217227                        <!--- Only execute once the framework has been initialized ---> 
    218                         <cfif getController().getColdboxInitiated()> 
     228                        <cfif instance.controller.getColdboxInitiated()> 
    219229                                <!--- InterceptMetadata ---> 
    220230                                <cfset interceptMetadata.cacheObjectKey = arguments.objectKey> 
     
    222232                                <cfset interceptMetadata.cacheObjectLastAccessTimeout = arguments.LastAccessTimeout> 
    223233                                <!--- Execute afterCacheElementInsert Interception ---> 
    224                                 <cfset getController().getInterceptorService().processState("afterCacheElementInsert",interceptMetadata)>                              
     234                                <cfset instance.controller.getInterceptorService().processState("afterCacheElementInsert",interceptMetadata)>                          
    225235                        </cfif> 
    226236                        <!--- Return True ---> 
     
    250260                        <cfset interceptMetadata.cacheObjectKey = arguments.objectKey> 
    251261                        <!--- Execute afterCacheElementInsert Interception ---> 
    252                         <cfset getController().getInterceptorService().processState("afterCacheElementRemoved",interceptMetadata)> 
     262                        <cfset instance.controller.getInterceptorService().processState("afterCacheElementRemoved",interceptMetadata)> 
    253263                </cfif> 
    254264                 
     
    297307                <!--- ************************************************************* ---> 
    298308                <cfscript> 
    299                         var cacheKey = getController().getHandlerService().EVENT_CACHEKEY_PREFIX & arguments.eventsnippet; 
     309                        var cacheKey = instance.controller.getHandlerService().EVENT_CACHEKEY_PREFIX & arguments.eventsnippet; 
    300310                         
    301311                        //Check if we are purging with query string 
     
    315325                <!--- ************************************************************* ---> 
    316326                <cfscript> 
    317                         var cacheKey = getController().getHandlerService().EVENT_CACHEKEY_PREFIX; 
     327                        var cacheKey = instance.controller.getHandlerService().EVENT_CACHEKEY_PREFIX; 
    318328                         
    319329                        /* Clear All Events */ 
     
    342352                <!--- ************************************************************* ---> 
    343353                <cfscript> 
    344                         var cacheKey = getController().getPlugin("renderer").VIEW_CACHEKEY_PREFIX; 
     354                        var cacheKey = instance.controller.getPlugin("renderer").VIEW_CACHEKEY_PREFIX; 
    345355                         
    346356                        /* Clear All the views */ 
     
    484494         
    485495        <!--- 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"> 
    487497                <cfscript> 
    488498                var x = 1; 
     
    536546         
    537547        <!--- 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."> 
    539549                <cfargument name="CacheConfigBean" type="coldbox.system.beans.cacheConfigBean" required="true"> 
    540550                <cfset instance.CacheConfigBean = arguments.CacheConfigBean> 
     
    549559        </cffunction> 
    550560         
    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          
    560561        <!--- Lock Name ---> 
    561562        <cffunction name="getlockName" access="public" output="false" returntype="string" hint="Get the lockName used for cache operations"> 
     
    570571        <!--- Get the Pool Metadata ---> 
    571572        <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         
    575582<!------------------------------------------- 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                 
    586584        <!--- Initialize our object cache pool ---> 
    587585        <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  
    88Date        :   11/14/2007 
    99Description : 
    10         This is an abstractEviction Policy object. 
     10        This is an AbstractEviction Policy object. 
    1111-----------------------------------------------------------------------> 
    12 <cfcomponent name="abstractEvictionPolicy" hint="An abstract cache eviction policy" output="false"> 
     12<cfcomponent name="AbstractEvictionPolicy" hint="An abstract cache eviction policy" output="false"> 
    1313 
    1414<!------------------------------------------- CONSTRUCTOR -------------------------------------------> 
  • coldbox/trunk/system/cache/policies/LFU.cfc

    r1533 r1699  
    88Date        :   11/14/2007 
    99Description : 
    10         This is an abstractEviction Policy object. 
     10        This is an AbstractEviction Policy object. 
    1111-----------------------------------------------------------------------> 
    1212<cfcomponent name="LFU"  
    1313                         output="false"  
    1414                         hint="LFU Eviction Policy Command"  
    15                          extends="coldbox.system.cache.policies.abstractEvictionPolicy"> 
     15                         extends="coldbox.system.cache.policies.AbstractEvictionPolicy"> 
    1616 
    1717<!------------------------------------------- CONSTRUCTOR -------------------------------------------> 
  • coldbox/trunk/system/cache/policies/LRU.cfc

    r1607 r1699  
    88Date        :   11/14/2007 
    99Description : 
    10         This is an abstractEviction Policy object. 
     10        This is an AbstractEviction Policy object. 
    1111-----------------------------------------------------------------------> 
    1212<cfcomponent name="LRU"  
    1313                         output="false"  
    1414                         hint="LFU Eviction Policy Command"  
    15                          extends="coldbox.system.cache.policies.abstractEvictionPolicy"> 
     15                         extends="coldbox.system.cache.policies.AbstractEvictionPolicy"> 
    1616 
    1717<!------------------------------------------- CONSTRUCTOR -------------------------------------------> 
  • coldbox/trunk/system/config/settings.xml

    r1646 r1699  
    4747        <!--ColdBox Cache Parameter: Whether reaping with default last access timeouts --> 
    4848        <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) --> 
    5050        <Setting name="CacheEvictionPolicy" value="LRU"/>  
    5151        <!-- Debugger settings --> 

Copyright 2006 ColdBox Framework by Luis Majano