Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17199 программистов и 1835 роботов. Сейчас ищут 1565 программистов ...

constructor Cache_Lite::Cache_Lite

Вернуться к: Cache_Lite

constructor Cache_Lite::Cache_Lite

constructor Cache_Lite::Cache_Lite() – Constructor

Synopsis

require_once 'Cache/Lite.php';

void constructor Cache_Lite::Cache_Lite ( array $options = array(NULL) )

The constructor of the Cache_Lite core class. You can give an associative array as an argument to set a lot of options.

Parameter

array $options

associative array to set a lot of options

Option Data Type Default Value Description
cacheDir string /tmp/ directory where to put the cache file (with a trailing slash at the end)
caching boolean TRUE enable / disable caching
lifeTime integer 3600 cache lifetime in seconds (since 1.6.0beta 1, you can use a null value for an eternal cache lifetime)
fileLocking boolean TRUE enable / disable fileLocking. Can avoid cache corruption under bad circumstances.
writeControl boolean TRUE enable / disable write control. Enable write control will lightly slow the cache writing but not the cache reading. Write control can detect some corrupt cache files but maybe it's not a perfect control.
readControl boolean TRUE enable / disable read control. If enabled, a control key is embeded in cache file and this key is compared with the one calculated after the reading
readControlType string crc32 Type of read control (only if read control is enabled). Must be 'md5' (for a md5 hash control (best but slowest)), 'crc32' (for a crc32 hash control (lightly less safe but faster)) or 'strlen' (for a length only test (fastest))
pearErrorMode integer CACHE_LITE_ERROR_RETURN pear error mode (when raiseError is called) (CACHE_LITE_ERROR_RETURN for just returning a PEAR_Error object or CACHE_LITE_ERROR_DIE for immediate stop of the script (good for debug) )
fileNameProtection boolean TRUE file Name protection (if set to true, you can use any cache id or group name, if set to false, it can be faster but cache ids and group names will be used directly in cache file names so be careful with special characters...)
automaticSerialization boolean FALSE enable / disable automatic serialization (allows non-string data to be saved, with a small performance decrease)
memoryCaching boolean FALSE enable / disable "Memory Caching" (NB : there is no lifetime for memory caching, only the end of the script)
onlyMemoryCaching boolean FALSE enable / disable "Only Memory Caching" (if enabled, files are not used anymore)
memoryCachingLimit integer 1000 max number of records to store into memory caching
automaticCleaningFactor integer 0 Disable / Tune the automatic cleaning process. The automatic cleaning process destroy too old (for the given life time) cache files when a new cache file is written. 0 means "no automatic cache cleaning", 1 means "systematic cache cleaning" (slow), x>1 means "automatic cleaning randomly 1 times on x cache writes". A value between 20 and 200 is maybe a good start.
hashedDirectoryLevel integer 0 Set the hashed directory structure level. 0 means "no hashed directory structure", 1 means "one level of directory", 2 means "two levels"... This option can speed up Cache_Lite only when you have many thousands of cache file. Only specific benchs can help you to choose the perfect value for you. Maybe, 1 or 2 is a good start.
errorHandlingAPIBreak boolean FALSE If set to true, it introduces a little API break but the error handling is better in CACHE_LITE_ERROR_RETURN mode (especially with the save() method which can return a PEAR_Error object).

Throws

No exceptions thrown.

Note

This function can not be called statically.

Example

Using most common options

<?php
require_once "Cache/Lite.php";

$options = array(
    
'cacheDir' => '/tmp/',
    
'lifeTime' => 7200,
    
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);

$cache = new Cache_Lite($options);

?>


Вернуться к: Cache_Lite

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware