/** * Read a Marker File Template from FileSystem or from Persistent (Memory) Cache if exists * !!! This is intended for very special usage ... !!! This is used automatically by the render_file_template() and used in combination with render_mixed_template() may produce the same results ... it make non-sense using it with render_template() as this should be used for internal (php) templates as all external templates should be loaded with render_file_template() * * @access private * @internal * * @param STRING $y_file_path :: The relative path to the file markers template * * @return STRING :: The template string * */ public static function read_template_file($y_file_path) { //-- $use_pcache = false; if ((string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') { if (defined('SMART_SOFTWARE_MKTPL_PCACHETIME')) { if (is_int(SMART_SOFTWARE_MKTPL_PCACHETIME)) { if ((int) SMART_SOFTWARE_MKTPL_PCACHETIME >= 0 and (int) SMART_SOFTWARE_MKTPL_PCACHETIME <= 31622400) { // 0 unlimited ; 1 sec .. 366 days $use_pcache = true; } //end if } //end if } //end if } //end if if ($use_pcache === true and SmartPersistentCache::isActive() and SmartPersistentCache::isMemoryBased()) { $the_cache_key = 'tpl__' . Smart::safe_pathname((string) Smart::base_name((string) $y_file_path)) . '__' . sha1((string) $y_file_path); } else { $the_cache_key = ''; } //end if else //-- $tpl = ''; //-- if ((string) $the_cache_key != '') { if (SmartPersistentCache::keyExists('smart-markers-templating', (string) $the_cache_key)) { $tpl = (string) SmartPersistentCache::getKey('smart-markers-templating', (string) $the_cache_key); if ((string) $tpl != '') { //Smart::log_notice('TPL found in cache: '.$y_file_path); return (string) $tpl; // return from persistent cache } //end if } //end if } //end if //-- $tpl = (string) SmartFileSystem::staticread((string) $y_file_path); if ((string) $the_cache_key != '') { if ((string) $tpl != '') { SmartPersistentCache::setKey('smart-markers-templating', (string) $the_cache_key . '__path', (string) $y_file_path, (int) SMART_SOFTWARE_MKTPL_PCACHETIME); // set to persistent cache SmartPersistentCache::setKey('smart-markers-templating', (string) $the_cache_key, (string) $tpl, (int) SMART_SOFTWARE_MKTPL_PCACHETIME); // set to persistent cache } //end if } //end if //-- return (string) $tpl; // return from fs read //-- }
private static function setInPersistentCache($the_cache_key, $y_data_arr) { //-- if (SmartPersistentCache::isActive() and SmartPersistentCache::isMemoryBased()) { if (Smart::array_size($y_data_arr) > 0) { SmartPersistentCache::setKey('smart-regional-texts', (string) $the_cache_key, (string) Smart::seryalize((array) $y_data_arr)); } //end if } //end if //-- }