Changeset 115258 in spip-zone
- Timestamp:
- May 6, 2019, 10:22:51 AM (2 years ago)
- Location:
- _plugins_/scssphp/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/scssphp/trunk/lib/scssphp/src/Cache.php
r115043 r115258 15 15 16 16 /** 17 * The scss cacher. 18 * 19 * In summary: 20 * 21 * TODO 17 * The scss cache manager. 18 * 19 * In short: 20 * 21 * allow to put in cache/get from fache a generic result from a known operation on a generic dataset, 22 * taking in account options that affects the result 23 * 24 * The cache manager is agnostic about data format and only the operation is expected to be descripted by string 25 * 22 26 */ 23 27 … … 39 43 public static $prefix = 'scssphp_'; 40 44 45 // force a refresh : 'once' for refreshing the first hit on a cache only, true to never use the cache in this hit 41 46 public static $force_refresh = false; 42 47 43 48 // specifies the number of seconds after which data cached will be seen as 'garbage' and potentially cleaned up 44 49 public static $gc_lifetime = 604800; 50 51 52 // array of already refreshed cache if $force_refresh==='once' 53 protected static $refreshed = []; 45 54 46 55 … … 76 85 77 86 /** 78 * Generic get 79 * Get the previous computed result of $what, affected by $options 87 * Get the cached result of $operation on $what, which is known as dependant from the content of $options 80 88 * 81 89 * @param string $operation 82 * parse, compile ?90 * parse, compile... 83 91 * @param $what 84 * content key (filename to be treated ?)92 * content key (filename to be treated for instance) 85 93 * @param array $options 86 94 * any option that affect the operation result on the content … … 94 102 $fileCache = self::$cache_dir . self::cacheName($operation, $what, $options); 95 103 96 if ( ! self::$force_refresh104 if ((! self::$force_refresh || (self::$force_refresh === 'once' && isset(self::$refreshed[$fileCache]))) 97 105 and file_exists($fileCache)) { 98 106 $cache_time = filemtime($fileCache); … … 110 118 } 111 119 120 /** 121 * Put in cache the result of $operation on $what, which is known as dependant from the content of $options 122 * 123 * @param string $operation 124 * @param $what 125 * @param $value 126 * @param array $options 127 */ 112 128 public function setCache($operation, $what, $value, $options = array()) 113 129 { … … 117 133 $c = serialize($c); 118 134 file_put_contents($fileCache, $c); 119 } 120 121 135 136 if (self::$force_refresh === 'once') { 137 self::$refreshed[$fileCache] = true; 138 } 139 } 140 141 142 /** 143 * get the cachename for the caching of $opetation on $what, which is known as dependant from the content of $options 144 * @param string $operation 145 * @param $what 146 * @param array $options 147 * @return string 148 */ 122 149 private static function cacheName($operation, $what, $options = array()) 123 150 { … … 139 166 140 167 168 /** 169 * Check that the cache dir is existing and writeable 170 * @throws Exception 171 */ 141 172 public static function checkCacheDir() 142 173 { -
_plugins_/scssphp/trunk/scssphp_fonctions.php
r115179 r115258 46 46 if (defined('_VAR_MODE') and 47 47 (_request('var_mode') == 'css' or in_array(_VAR_MODE, array('css', 'recalcul'))) ) { 48 $cache_options['force_refresh'] = true;48 $cache_options['force_refresh'] = 'once'; 49 49 } 50 50
Note: See TracChangeset
for help on using the changeset viewer.