Changeset 1703

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

Finalized afterCacheElementExpired core interception point.

Files:

Legend:

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

    r1699 r1703  
    422422                                                //Check for creation timeouts and clear 
    423423                                                if ( dateDiff("n", poolStruct[thisKey].created, now() ) gte poolStruct[thisKey].Timeout ){ 
     424                                                        /* Clear The Key */ 
    424425                                                        clearKey(thisKey); 
     426                                                        /* Announce Expiration */ 
     427                                                        announceExpiration(thisKey); 
    425428                                                        continue; 
    426429                                                } 
     
    428431                                                if ( ccBean.getCacheUseLastAccessTimeouts() and  
    429432                                                     dateDiff("n", poolStruct[thisKey].lastAccesed, now() ) gte ccBean.getCacheObjectDefaultLastAccessTimeout() ){ 
     433                                                        /* Clear the Key */ 
    430434                                                        clearKey(thisKey); 
     435                                                        /* Announce Expiration */ 
     436                                                        announceExpiration(thisKey); 
    431437                                                        continue; 
    432438                                                } 
     
    581587         
    582588<!------------------------------------------- PRIVATE -------------------------------------------> 
    583                  
     589         
     590        <!--- announceExpiration ---> 
     591        <cffunction name="announceExpiration" output="false" access="private" returntype="void" hint="Announce an Expiration"> 
     592                <cfargument name="objectKey" type="string" required="true" hint="The object key to announce expiration"/> 
     593                <cfscript> 
     594                        var interceptData = structnew(); 
     595                        /* interceptData */ 
     596                        interceptData.cacheObjectKey = arguments.objectKey; 
     597                        /* Execute afterCacheElementExpired Interception */ 
     598                        instance.controller.getInterceptorService().processState("afterCacheElementExpired",interceptData); 
     599                </cfscript> 
     600        </cffunction> 
     601         
    584602        <!--- Initialize our object cache pool ---> 
    585603        <cffunction name="initPool" access="private" output="false" returntype="void" hint="Initialize and set the internal object Pool"> 
  • coldbox/trunk/testing/tests/cases/cache/CacheManagerTest.cfc

    r1647 r1703  
    1515                <cfscript> 
    1616                super.setup(); 
     17                mockController = mockfactory.createMock('coldbox.system.controller'); 
     18                mockService = mockFactory.createMock('coldbox.system.services.interceptorService'); 
     19                 
     20                mockController.mockMethod('getInterceptorService').returns(mockService); 
     21                mockController.mockMethod('getAppHash').returns(hash(createUUID()) ); 
     22                 
     23                ccbean = createObject("component","coldbox.system.beans.cacheConfigBean"); 
     24                memento = structnew(); 
     25                memento.CacheObjectDefaultTimeout = 20; 
     26                memento.CacheObjectDefaultLastAccessTimeout = 20; 
     27                memento.CacheReapFrequency = 1; 
     28                memento.CacheMaxObjects = 100; 
     29                memento.CacheFreeMemoryPercentageThreshold = 1; 
     30                memento.CacheUseLastAccessTimeouts = true; 
     31                memento.CacheEvictionPolicy = "FIFO"; 
     32                ccbean.init(argumentCollection=memento); 
     33                 
     34                cm = createObject("component","coldbox.system.cache.cacheManager").init(mockController); 
    1735                </cfscript> 
    1836        </cffunction> 
    1937         
    20         <cffunction name="testConfigs" access="public" returntype="void" hint="" output="false" > 
     38        <cffunction name="testConfigure" access="public" returntype="void" hint="" output="false" > 
    2139                <cfscript> 
    22                         var local = structnew(); 
    23                          
    24                          
     40                        cm.configure(ccbean); 
     41                </cfscript> 
     42        </cffunction> 
     43         
     44        <cffunction name="testannounceExpiration" output="false"> 
     45                <cfscript> 
     46                        makePublic(cm,"announceExpiration","_announceExpiration"); 
     47                        cm._announceExpiration('test'); 
    2548                </cfscript> 
    2649        </cffunction> 

Copyright 2006 ColdBox Framework by Luis Majano