@@ 330-353 (lines=24) @@ | ||
327 | * |
|
328 | * @return this |
|
329 | */ |
|
330 | protected function SetCfgDefault () { |
|
331 | parent::SetCfgDefault(); |
|
332 | ||
333 | // Cache type: file, memcached |
|
334 | $this->aCfg['cache-type'] = ''; |
|
335 | ||
336 | // Type file: dir where data file store |
|
337 | $this->aCfg['cache-file-dir'] = ''; |
|
338 | /** |
|
339 | * Type file: cache file store rule |
|
340 | * |
|
341 | * Group by every 2-chars, their means: |
|
342 | * 10 first 2 char of md5 hash, 16 * 16 = 256 |
|
343 | * 11 3-4 char of md5 hash |
|
344 | * 20 last 2 char of md5 hash |
|
345 | * 30 first 2 char of key |
|
346 | * 40 last 2 char of key |
|
347 | * 5n crc32, n=0..3, 16 * 16 = 256 |
|
348 | * Join these str with '/', got full path of cache file. |
|
349 | */ |
|
350 | $this->aCfg['cache-file-rule'] = ''; |
|
351 | ||
352 | return $this; |
|
353 | } // end of func SetCfgDefault |
|
354 | ||
355 | ||
356 | /** |
@@ 306-332 (lines=27) @@ | ||
303 | * |
|
304 | * @return this |
|
305 | */ |
|
306 | protected function SetCfgDefault () { |
|
307 | parent::SetCfgDefault(); |
|
308 | ||
309 | // Cache type: file |
|
310 | $this->aCfg['cache-type'] = 'file'; |
|
311 | ||
312 | ||
313 | // Dir where data file store |
|
314 | $this->aCfg['cache-file-dir'] = '/tmp/cache/'; |
|
315 | ||
316 | /** |
|
317 | * Cache file store rule |
|
318 | * |
|
319 | * Group by every 2-chars, their means: |
|
320 | * 10 first 2 char of md5 hash, 16 * 16 = 256 |
|
321 | * 11 3-4 char of md5 hash |
|
322 | * 20 last 2 char of md5 hash |
|
323 | * 30 first 2 char of key |
|
324 | * 40 last 2 char of key |
|
325 | * 5n crc32, n=0..3, 16 * 16 = 256 |
|
326 | * Join these str with '/', got full path of cache file. |
|
327 | */ |
|
328 | $this->aCfg['cache-file-rule'] = '10'; |
|
329 | ||
330 | ||
331 | return $this; |
|
332 | } // end of func SetCfgDefault |
|
333 | ||
334 | ||
335 | } // end of class CacheFile |
@@ 203-227 (lines=25) @@ | ||
200 | * |
|
201 | * @return this |
|
202 | */ |
|
203 | protected function SetCfgDefault () { |
|
204 | parent::SetCfgDefault(); |
|
205 | ||
206 | // Cache type: file, memcached |
|
207 | // Empty means parent cache class. |
|
208 | $this->aCfg['cache-type'] = ''; |
|
209 | ||
210 | // Cache store method |
|
211 | // 0: Raw string or other value. |
|
212 | // User should determine the value DO suite cache type. |
|
213 | // 1: Json, decode to array. |
|
214 | // 2: Json, decode to object. |
|
215 | $this->aCfg['cache-store-method'] = 1; |
|
216 | ||
217 | // Default cache lifetime, in second |
|
218 | // Can be overwrite by param when get/set. |
|
219 | // Default/Max 30days: |
|
220 | // 60sec * 60min = 3600s * 24h = 86400s * 30 = 2592000s |
|
221 | // Larger than 30days, must assign unix time like memcached, |
|
222 | // which is number of seconds since 1970-1-1 as an integer. |
|
223 | // 0 means forever. |
|
224 | $this->aCfg['cache-lifetime'] = 2592000; |
|
225 | ||
226 | return $this; |
|
227 | } // end of func SetCfgDefault |
|
228 | ||
229 | ||
230 | /** |