Ignore:
Timestamp:
01/14/12 16:18:10 (4 months ago)
Author:
bogdan2412
Message:

Make infoarena compatible with HPHP.

  • Implemented APC caching support since eaccelerator is not compatible with HPHP and although we support memcached, we do not use it on live.
  • Replaced instances of create_function_cached with php anonymous functions. This bumps the PHP version requirement to 5.3, but it allows the code to work with HPHP, since dynamic function generation is replaced with staticly analyzable functions. This also removes a horrible, terrible hack in Textile.php which was storing the current instance of the Textile class being processed as a static variable so that it could be accessed by anonymous functions.
  • Replaced occurrences of assert with log_assert.
  • When running under HPHP, IA_HPHP_ENV is defined and is used to bypass some incompatible code (redundant ini configuration checks).
  • Fixed some includes that were dependent on the working directory being www/
  • Included a sample HPHP configuration file and a Makefile with compilation commands.

REVIEW URL: http://reviewboard.infoarena.ro/r/182/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/cache.php

    r966 r1164  
    144144//      mem_cache_purge deletes everything from the cache. Try to avoid calling it. 
    145145// 
    146 // FIXME: cache is not logged. See IA_LOG_MEM_CACHE. 
    147146if (IA_MEM_CACHE_METHOD == 'none') { 
    148147 
     
    259258        } 
    260259    } 
     260 
     261} else if (IA_MEM_CACHE_METHOD == 'apc') { 
     262    // APC cache implementation 
     263    function mem_cache_get($cache_id) { 
     264        $res = apc_fetch($cache_id); 
     265        if ($res === false) { 
     266            if (IA_LOG_MEM_CACHE) { 
     267                log_print("MEM CACHE: miss on $cache_id"); 
     268            } 
     269            return false; 
     270        } else { 
     271            if (IA_LOG_MEM_CACHE) { 
     272                log_print("MEM CACHE: hit on $cache_id"); 
     273            } 
     274            return unserialize($res); 
     275        } 
     276    } 
     277 
     278    function mem_cache_set($cache_id, $object, $ttl = IA_MEM_CACHE_EXPIRATION) { 
     279        log_assert($object !== 'false', "Can't cache false values"); 
     280        apc_store($cache_id, serialize($object), $ttl); 
     281 
     282        if (IA_LOG_MEM_CACHE) { 
     283            log_print("MEM CACHE: store $cache_id"); 
     284        } 
     285        return $object; 
     286    } 
     287 
     288    function mem_cache_delete($cache_id) { 
     289        apc_delete($cache_id); 
     290        if (IA_LOG_MEM_CACHE) { 
     291            log_print("MEM CACHE: delete $cache_id"); 
     292        } 
     293    } 
     294 
     295    function mem_cache_purge() { 
     296        if (IA_LOG_MEM_CACHE) { 
     297            log_print("MEM CACHE: purge"); 
     298        } 
     299        apc_clear_cache(); 
     300    } 
    261301} 
    262302 
Note: See TracChangeset for help on using the changeset viewer.