[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] =?utf-8?q?svn:_/phd/trunk/phpdotnet/phd/_Config.php_Format.php_Index.php_Options/Handler.p
From: Hannes_Magnusson <bjori () php ! net>
Date: 2011-04-27 18:33:37
Message-ID: svn-bjori-1303929217-310590-1931069302 () svn ! php ! net
[Download RAW message or body]
bjori Wed, 27 Apr 2011 18:33:37 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310590
Log:
Add --memoryindex (-M) to just store the index in memory
# couple of percentages less :)
Changed paths:
U phd/trunk/phpdotnet/phd/Config.php
U phd/trunk/phpdotnet/phd/Format.php
U phd/trunk/phpdotnet/phd/Index.php
U phd/trunk/phpdotnet/phd/Options/Handler.php
Modified: phd/trunk/phpdotnet/phd/Config.php
===================================================================
--- phd/trunk/phpdotnet/phd/Config.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Config.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -51,6 +51,8 @@
'package_dirs' => array(__INSTALLDIR__),
'saveconfig' => false,
'quit' => false,
+ 'indexcache' => '',
+ 'memoryindex' => '',
);
private static $optionArray = null;
Modified: phd/trunk/phpdotnet/phd/Format.php
===================================================================
--- phd/trunk/phpdotnet/phd/Format.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Format.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -53,8 +53,14 @@
protected $buffer = "";
public function __construct() {
- if (file_exists(Config::output_dir() . "index.sqlite")) {
- $this->sqlite = new \SQLite3(Config::output_dir() . 'index.sqlite');
+ $sqlite = Config::indexcache();
+ if (!$sqlite) {
+ if (file_exists(Config::output_dir() . "index.sqlite")) {
+ $sqlite = new \SQLite3(Config::output_dir() . 'index.sqlite');
+ }
+ }
+ if ($sqlite) {
+ $this->sqlite = $sqlite;
$this->sortIDs();
}
}
Modified: phd/trunk/phpdotnet/phd/Index.php
===================================================================
--- phd/trunk/phpdotnet/phd/Index.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Index.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -149,13 +149,15 @@
break;
case Render::INIT:
if ($value) {
- if (file_exists(Config::output_dir() . "index.sqlite")) {
- $db = new \SQLite3(Config::output_dir() . 'index.sqlite');
- $db->exec('DELETE FROM ids');
- $db->exec('DELETE FROM indexing');
+ if (Config::memoryindex()) {
+ $db = new \SQLite3(":memory:");
} else {
$db = new \SQLite3(Config::output_dir() . 'index.sqlite');
- $create = <<<SQL
+ $db->exec('DROP TABLE IF EXISTS ids');
+ $db->exec('DROP TABLE IF EXISTS indexing');
+ }
+
+ $create = <<<SQL
CREATE TABLE ids (
docbook_id TEXT,
filename TEXT,
@@ -171,13 +173,16 @@
time INTEGER PRIMARY KEY
);
SQL;
- $db->exec('PRAGMA default_synchronous=OFF');
- $db->exec('PRAGMA count_changes=OFF');
- $db->exec('PRAGMA cache_size=100000');
- $db->exec($create);
+ $db->exec('PRAGMA default_synchronous=OFF');
+ $db->exec('PRAGMA count_changes=OFF');
+ $db->exec('PRAGMA cache_size=100000');
+ $db->exec($create);
+
+ if (Config::memoryindex()) {
+ Config::set_indexcache($db);
}
+
$this->db = $db;
-
$this->chunks = array();
} else {
print_r($this->chunks);
Modified: phd/trunk/phpdotnet/phd/Options/Handler.php
===================================================================
--- phd/trunk/phpdotnet/phd/Options/Handler.php 2011-04-27 18:25:29 UTC (rev 310589)
+++ phd/trunk/phpdotnet/phd/Options/Handler.php 2011-04-27 18:33:37 UTC (rev 310590)
@@ -28,9 +28,19 @@
'ext:' => 'e:', // The file-format extension to use, \
including the dot 'saveconfig::' => 'S::', // Save the generated config ?
'quit' => 'Q', // Do not run the render. Use with -S to \
just save the config. + 'memoryindex' => 'M', // Use sqlite in \
memory rather then file );
}
+ public function option_M($k, $v)
+ {
+ $this->option_memoryindex($k, $v);
+ }
+ public function option_memoryindex($k, $v)
+ {
+ Config::set_memoryindex(true);
+ }
+
public function option_f($k, $v)
{
$this->option_format($k, $v);
@@ -347,6 +357,9 @@
-I
--noindex Do not index before rendering but load from cache
(default: false)
+ -M
+ --memoryindex Do not save indexing into a file, store it in memory.
+ (default: false)
-r
--forceindex Force re-indexing under all circumstances
(default: false)
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic