Subversion Repositories Applications.framework

Rev

Rev 269 | Rev 288 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 269 Rev 282
Line 1... Line 1...
1
<?php
1
<?php
2
class CacheSqlite {
2
class CacheSqlite {
3
	/**
3
	/**
4
	 * Available options
4
	 * Options disponibles :
5
	 *
5
	 *
6
	 * =====> (string) cache_db_complete_path :
6
	 * ====> (string) stockage_chemin :
-
 
7
	 * Chemin vers le fichier contenant la base SQLite.
-
 
8
	 * 
-
 
9
	 *
-
 
10
	 * ====> (int) defragmentation_auto :
7
	 * - the complete path (filename included) of the SQLITE database
11
	 * - Désactive / Régler le processus de défragmentation automatique
-
 
12
	 * - Le processus de défragmentation automatiques réduit la taille du fichier contenant la base de données
-
 
13
	 *   quand un ajout ou une suppression de cache est réalisée :
-
 
14
	 *	 0			   => pas de défragmentation automatique
-
 
15
	 *	 1			   => défragmentation automatique systématique
-
 
16
	 *	 x (integer) > 1 => défragmentation automatique toutes les 1 fois (au hasard) sur x ajout ou suppression de cache
8
	 *
17
	 *
9
	 * ====> (int) automatic_vacuum_factor :
-
 
10
	 * - Disable / Tune the automatic vacuum process
-
 
11
	 * - The automatic vacuum process defragment the database file (and make it smaller)
-
 
12
	 *   when a clean() or delete() is called
-
 
13
	 *	 0			   => no automatic vacuum
-
 
14
	 *	 1			   => systematic vacuum (when delete() or clean() methods are called)
-
 
15
	 *	 x (integer) > 1 => automatic vacuum randomly 1 times on x clean() or delete()
-
 
16
	 *
-
 
17
	 * @var array Available options
18
	 * @var array options disponibles
18
	 */
19
	 */
19
	protected $options = array(
20
	protected $options = array(
20
		'stockage_chemin' => null,
21
		'stockage_chemin' => null,
21
		'defragmentation_auto' => 10
22
		'defragmentation_auto' => 10
22
	);
23
	);
Line 45... Line 46...
45
	 * @return void
46
	 * @return void
46
	 */
47
	 */
47
	public function __construct(array $options = array(), Cache $cache) {
48
	public function __construct(array $options = array(), Cache $cache) {
48
		$this->Cache = $cache;
49
		$this->Cache = $cache;
49
		if (extension_loaded('sqlite')) {
50
		if (extension_loaded('sqlite')) {
-
 
51
			$this->initialiserOptionsParConfig();
50
			$this->setOptions($options);
52
			$this->setOptions($options);
51
		} else {
53
		} else {
52
			$e = "Impossible d'utiliser le cache SQLITE car l'extenssion 'sqlite' n'est pas chargée dans l'environnement PHP courrant.";
54
			$e = "Impossible d'utiliser le cache SQLITE car l'extenssion 'sqlite' n'est pas chargée dans l'environnement PHP courrant.";
53
			trigger_error($e, E_USER_ERROR);
55
			trigger_error($e, E_USER_ERROR);
54
		}
56
		}
55
	}
57
	}
Line -... Line 58...
-
 
58
	
-
 
59
	private function initialiserOptionsParConfig() {
-
 
60
		while (list($nom, $valeur) = each($this->options)) {
-
 
61
			if (Config::existe($nom)) {
-
 
62
				$this->options[$nom] = Config::get($nom);
-
 
63
			}
-
 
64
		}
-
 
65
	}
56
	
66
	
57
	/**
67
	/**
58
	 * Destructor
68
	 * Destructor
59
	 *
69
	 *
60
	 * @return void
70
	 * @return void