svnno****@sourc*****
svnno****@sourc*****
2010年 1月 16日 (土) 05:56:23 JST
Revision: 784 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=784 Author: rsk Date: 2010-01-16 05:56:23 +0900 (Sat, 16 Jan 2010) Log Message: ----------- expack: - P2KeyValueStore_FunctionCache::invoke() ã«å®è¡ããé¢æ°åã "class::method" å½¢å¼ã®æååã§ä¸ããããã¨ãã®ä¸å ·åãä¿®æ£ã - ImageCache2ã®ç»åä¸è¦§ã§ä½¿ãé¢æ°ãã£ãã·ã¥æ©æ§ãPEAR Cache_DBãã P2KeyValueStore_FunctionCache_Proxyã«å¤æ´ã - ä¸è¨å¤æ´ã«ä¼´ããä¸è¦ã«ãªã£ã lib/pear_hack ãã£ã¬ã¯ããªãåé¤ã Modified Paths: -------------- p2ex/trunk/conf/conf.inc.php p2ex/trunk/conf/conf_ic2.inc.php p2ex/trunk/doc/ImageCache2/ic2_install.phps p2ex/trunk/ic2_manager.php p2ex/trunk/iv2.php p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html p2ex/trunk/lib/expack/tgrep/view.inc.php p2ex/trunk/lib/expack/tgrep/view_k.inc.php Removed Paths: ------------- p2ex/trunk/lib/pear_hack/ -------------- next part -------------- Modified: p2ex/trunk/conf/conf.inc.php =================================================================== --- p2ex/trunk/conf/conf.inc.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/conf/conf.inc.php 2010-01-15 20:56:23 UTC (rev 784) @@ -304,6 +304,7 @@ $_conf['cookie_db_path'] = $_conf['db_dir'] . '/p2_cookies.sqlite3'; $_conf['post_db_path'] = $_conf['db_dir'] . '/p2_post_data.sqlite3'; $_conf['hostcheck_db_path'] = $_conf['db_dir'] . '/p2_hostcheck_cache.sqlite3'; + $_conf['iv2_cache_db_path'] = $_conf['db_dir'] . '/iv2_cache.sqlite3'; // â³ if ($_conf['expack.use_pecl_http'] && !extension_loaded('http')) { Modified: p2ex/trunk/conf/conf_ic2.inc.php =================================================================== --- p2ex/trunk/conf/conf_ic2.inc.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/conf/conf_ic2.inc.php 2010-01-15 20:56:23 UTC (rev 784) @@ -14,10 +14,8 @@ // MySQL: "mysql://username:password@localhost:3306/database" // PostgreSQL: "pgsql://username:password@localhost:5432/database" // SQLite2: "sqlite:///./cache/imgcache.sqlite" -// SQLite3: "sqlite3:///./cache/imgcache.sqlite3" // 1: username,password,databaseÍÀÛÌàÌÆÇÝÖ¦éB // 2: MySQL,PosrgreSQLÅÍ\ßf[^x[XðìÁĨB -// 3: SQlite3ÌT|[gÍÀ±IÈàÌÅAñ§ $_conf['expack.ic2.general.dsn'] = ""; // DBÅg¤e[u¼ @@ -65,24 +63,6 @@ $_conf['expack.ic2.general.redirect'] = 1; // }}} -// {{{ f[^LbV - -// f[^ðLbV ·é½ßÌe[u¼ -$_conf['expack.ic2.cache.table'] = "datacache"; - -// LbV ÌLøúÀibj -// 1Ô=3600 -// 1ú=86400 -// 1TÔ=604800 -$_conf['expack.ic2.cache.expires'] = 3600; - -// LbV ·éf[^ÌÅåÊioCgj -$_conf['expack.ic2.cache.highwater'] = 2048000; - -// LbV µ½f[^ªhighwater𴦽ƫA±ÌlÜŸç·ioCgj -$_conf['expack.ic2.cache.lowwater'] = 1536000; - -// }}} // {{{ ê // y[W^Cg @@ -96,9 +76,14 @@ $_conf['expack.ic2.viewer.delete_src_not_exists'] = 0; // \¦pɲ®µ½æîñðLbV (off:0;on:1) -// LbV ÌLøúÀÈÇÍuf[^LbV vÌÅÝè $_conf['expack.ic2.viewer.cache'] = 0; +// LbV ÌLøúÀibj +// 1Ô=3600 +// 1ú=86400 +// 1TÔ=604800 +$_conf['expack.ic2.viewer.cache_lifetime'] = 3600; + // d¡æðÅÉqbg·é1¾¯\¦ (off:0;on:1) // TuNGÉεĢȢMySQL 4.1¢ÅLøÉ·éÆG[ªoé $_conf['expack.ic2.viewer.unique'] = 0; Modified: p2ex/trunk/doc/ImageCache2/ic2_install.phps =================================================================== --- p2ex/trunk/doc/ImageCache2/ic2_install.phps 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/doc/ImageCache2/ic2_install.phps 2010-01-15 20:56:23 UTC (rev 784) @@ -132,27 +132,6 @@ 'size, md5, mime' ); -// åÉæLbV êÅg¤f[^LbV pe[u -$datacache_table_quoted = $db->quoteIdentifier($ini['Cache']['table']); -$createTableSQL['datacache'] = <<<EOQ -CREATE TABLE $datacache_table_quoted ( - id CHAR(32) NOT NULL, - cachegroup VARCHAR (127) NOT NULL, - cachedata TEXT, - userdata VARCHAR (255), - expires INTEGER NOT NULL, - changed INTEGER NOT NULL DEFAULT 0, - PRIMARY KEY (id, cachegroup) -)$table_extra_defs; -EOQ; - -// f[^LbV pe[uÌCfbNXiLøúÀj -$createIndexSQL['datacache_expires'] = sprintf($format_createIndex, - $db->quoteIdentifier('idx_'.$ini['Cache']['table'].'_expires'), - $datacache_table_quoted, - 'expires' -); - // G[Ope[u $ic2error_table_quoted = $db->quoteIdentifier($ini['General']['error_table']); $createTableSQL['ic2_error'] = <<<EOQ Modified: p2ex/trunk/ic2_manager.php =================================================================== --- p2ex/trunk/ic2_manager.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/ic2_manager.php 2010-01-15 20:56:23 UTC (rev 784) @@ -105,11 +105,14 @@ break; case 'clearCache': - $result = $db->query('DELETE FROM ' . $db->quoteIdentifier($ini['Cache']['table'])); - if (DB::isError($result)) { - $_info_msg_ht .= $result->getMessage(); - } else { - $_info_msg_ht .= "<p>e[u {$ini['Cache']['table']} ðóɵܵ½B</p>"; + if (file_exists($_conf['iv2_cache_db_path'])) { + $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], + P2KeyValueStore::CODEC_SERIALIZING); + if ($kvs->clear() === false) { + $_info_msg_ht .= '<p>ê\¦pÌf[^LbV ðÁūܹñŵ½B</p>'; + } else { + $_info_msg_ht .= '<p>ê\¦pÌf[^LbV ðÁµÜµ½B</p>'; + } } $result_files = P2Util::garbageCollection($flexy->options['compileDir'], -1, '', '', TRUE); $removed_files = $result_files['successed']; @@ -140,21 +143,24 @@ break; case 'vacuumDB': + // SQLite2 ÌæLbV f[^x[XðVACUUM if ($db->dsn['phptype'] == 'sqlite') { - $db_file = $db->dsn['database']; - $size_b = filesize($db_file); $result = $db->query('VACUUM'); if (DB::isError($result)) { $_info_msg_ht .= $result->getMessage(); } else { - clearstatcache(); - $size_a = filesize($db_file); - $_info_msg_ht .= sprintf('<p>VACUUMÀsAt@CTCY: %s ¨ %s (-%s)', - number_format($size_b), - number_format($size_a), - number_format($size_b - $size_a)); + $_info_msg_ht .= '<p>æf[^x[Xð®µÜµ½B</p>'; } } + + // SQLite3 Ìê\¦pf[^LbV ðVACUUM + if (file_exists($_conf['iv2_cache_db_path'])) { + $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], + P2KeyValueStore::CODEC_SERIALIZING); + $kvs->vacuum(); + unset($kvs); + $_info_msg_ht .= '<p>ê\¦pÌf[^LbV ð®µÜµ½B</p>'; + } break; default: @@ -172,9 +178,6 @@ $flexy->setData('skin', $skin_en); $flexy->setData('php_self', $_SERVER['SCRIPT_NAME']); $flexy->setData('info_msg', $_info_msg_ht); -if ($db->dsn['phptype'] == 'sqlite') { - $flexy->setData('isSQLite', TRUE); -} $flexy->setData('pc', !$_conf['ktai']); $flexy->setData('iphone', $_conf['iphone']); $flexy->setData('doctype', $_conf['doctype']); Modified: p2ex/trunk/iv2.php =================================================================== --- p2ex/trunk/iv2.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/iv2.php 2010-01-15 20:56:23 UTC (rev 784) @@ -169,57 +169,45 @@ $thumb = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_DEFAULT); if ($ini['Viewer']['cache']) { - // f[^LbV ÉÍCache_Container_db(Cache 1.5.4)ðnbNµÄMySQLÈOÉàγ¹A - // RXgN^ªDB_xxx(DB_mysqlÈÇ)ÌCX^Xðó¯æêéæ¤Éµ½àÌðg¤B - // it@C¼ENX¼Í¯¶ÅAinclude_pathð²®µÄ - // IWiÌCache/Container/db.phpÌãíèÉ·éj - $cache_options = array( - 'dsn' => $ini['General']['dsn'], - 'cache_table' => $ini['Cache']['table'], - 'highwater' => (int)$ini['Cache']['highwater'], - 'lowwater' => (int)$ini['Cache']['lowwater'], - 'db' => $db - ); - $cache = new Cache_Function('db', $cache_options, (int)$ini['Cache']['expires']); - // LøúÀØêLbV ÌK[xbWRNVÈÇ - if (isset($_GET['cache_clean'])) { - $cache_clean = $_GET['cache_clean']; - } elseif (isset($_POST['cache_clean'])) { - $cache_clean = $_POST['cache_clean']; + $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], + P2KeyValueStore::CODEC_SERIALIZING); + $cache_lifetime = (int)$ini['Viewer']['cache_lifetime']; + if (array_key_exists('cache_clean', $_REQUEST)) { + $cache_clear = $_REQUEST['cache_clean']; } else { - $cache_clean = false; + $cache_clear = false; } - switch ($cache_clean) { - // LbV ðSí - case 'all': - $sql = sprintf('DELETE FROM %s', $db->quoteIdentifier($ini['Cache']['table'])); - $result = $db->query($sql); + $do_vacuum = false; + + if ($cache_clear == 'all') { + $kvs->clear(); + $do_vacuum = true; + } elseif ($cache_clear == 'gc') { + $kvs->gc($cache_lifetime); + $do_vacuum = true; + } + + if ($do_vacuum) { + // LbV ðVACUUM + + // SQLiteÈçVACUUMðÀs + if ($db_class == 'db_sqlite') { + $result = $db->query('VACUUM'); if (DB::isError($result)) { p2die($result->getMessage()); } - $vacuumdb = true; - break; - // §IÉK[xbWRNV - case 'gc': - $cache->garbageCollection(true); - $vacuumdb = true; - break; - // gc_probability(ftHgÍ1)/100Ìm¦ÅK[xbWRNV - default: - // $cache->gc_probability = 1; - $cache->garbageCollection(); - $vacuumdb = false; - } - // SQLiteÈçVACUUMðÀsiPostgreSQLÍÊcronÅvacuumdb·éÌű±Å͵Ȣj - if ($vacuumdb && $db_class == 'db_sqlite') { - $result = $db->query('VACUUM'); - if (DB::isError($result)) { - p2die($result->getMessage()); } } - $enable_cache = true; + + $cache = new P2KeyValueStore_FunctionCache($kvs); + $cache->setLifeTime($cache_lifetime); + $imageInfo_getExtraInfo = $cache->getProxy('IC2_ImageInfo::getExtraInfo'); + $imageInfo_getExifData = $cache->getProxy('IC2_ImageInfo::getExifData'); + $editForm_imgManager = $cache->getProxy('IC2_EditForm::imgManager'); + + $use_cache = true; } else { - $enable_cache = false; + $use_cache = false; } // }}} @@ -808,13 +796,13 @@ unset($img['rank'], $img['memo']); // \¦pÏðÝè - if ($enable_cache) { - $add = $cache->call('IC2_ImageInfo::getExtraInfo', $img); + if ($use_cache) { + $add = $imageInfo_getExtraInfo->invoke($img); if ($mode == 1) { $chk = IC2_EditForm::imgChecker($img); // ärIy¢ÌÅLbV µÈ¢ $add += $chk; } elseif ($mode == 2) { - $mng = $cache->call('IC2_EditForm::imgManager', $img, $status); + $mng = $editForm_imgManager->invoke($img, $status); $add += $mng; } } else { @@ -859,7 +847,11 @@ // Exifîñðæ¾ if ($show_exif && file_exists($add['src']) && $img['mime'] == 'image/jpeg') { - $item['exif'] = $enable_cache ? $cache->call('IC2_ImageInfo::getExifData', $add['src']) : IC2_ImageInfo::getExifData($add['src']); + if ($use_cache) { + $item['exif'] = $imageInfo_getExifData->invoke($add['src']); + } else { + $item['exif'] = IC2_ImageInfo::getExifData($add['src']); + } } else { $item['exif'] = null; } Modified: p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php 2010-01-15 20:56:23 UTC (rev 784) @@ -28,8 +28,13 @@ if (!is_callable($function)) { throw new InvalidArgumentException('Non-callable value was given'); } + $this->_cache = $cache; - $this->_function = $function; + if (is_string($function) && strpos($function, '::') !== false) { + $this->_function = explode('::', $function, 2); + } else { + $this->_function = $function; + } $this->_prependedParameters = array(); $this->_appendedParameters = array(); $this->_lifeTime = -1; Modified: p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php 2010-01-15 20:56:23 UTC (rev 784) @@ -58,6 +58,9 @@ // Ö¼ if (is_string($function)) { $name = $function; + if (strpos($function, '::') !== false) { + $function = explode('::', $function, 2); + } } elseif (is_object($function)) { $name = get_class($function) . '->__invoke'; } elseif (is_object($function[0])) { Modified: p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html =================================================================== --- p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html 2010-01-15 20:56:23 UTC (rev 784) @@ -84,9 +84,9 @@ [<a href="ic2_viewtable.php?table=blacklist#footer" target="read">ubNXgð©é</a>] </div> - <div flexy:if="isSQLite"> + <div> <input type="radio" name="action" id="action_vacuumDB" value="vacuumDB" onclick="dropZeroOptions(false)" /> - <label for="action_vacuumDB">f[^x[Xð®·éiSQLiteÌÝj</label> + <label for="action_vacuumDB">f[^x[Xð®·é</label> <!-- VACUUMðÀs --> </div> Modified: p2ex/trunk/lib/expack/tgrep/view.inc.php =================================================================== --- p2ex/trunk/lib/expack/tgrep/view.inc.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/lib/expack/tgrep/view.inc.php 2010-01-15 20:56:23 UTC (rev 784) @@ -79,7 +79,7 @@ <li>2ÂÚÈ~ÌL[[hŪÉ"-"ð¯éÆA»êðÜÜÈ¢à̪o³êÜ·B</li> <li>" Ü½Í ' ÅÍÜ꽪ÍXy[XªüÁÄ¢ÄàêÂÌL[[hƵĵ¢Ü·B</li> <li>L[[hÌSp¼pA嶬¶Í³³êÜ·B</li> - <li>f[^x[XÌXVpxÍ3ÔÉ1ñÅAXE¨¢E³ÍXV_ÅÌlÅ·B</li> + <li>f[^x[XÌXVpxÍ1ÔÉ1ñÅAXE¨¢E³ÍXV_ÅÌlÅ·B</li> </uL> </div> <?php } ?> Modified: p2ex/trunk/lib/expack/tgrep/view_k.inc.php =================================================================== --- p2ex/trunk/lib/expack/tgrep/view_k.inc.php 2010-01-15 19:28:32 UTC (rev 783) +++ p2ex/trunk/lib/expack/tgrep/view_k.inc.php 2010-01-15 20:56:23 UTC (rev 784) @@ -40,7 +40,7 @@ <li>2ÂÚÈ~Ì·°Ü°ÄÞŪÉ"-"ð¯éƤ»êðÜÜÈ¢à̪o³êÜ·¡</li> <li>" Ü½Í ' ÅÍÜ꽪ͽÍß°½ªüÁÄ¢ÄàêÂÌ·°Ü°ÄÞƵĵ¢Ü·¡</li> <li>·°Ü°ÄÞÌSp¼p¤å¶¬¶Í³³êÜ·¡</li> -<li>ÃÞ°ÀÍÞ°½ÌXVpxÍ3ÔÉ1ñŤڽ¥¨¢¥³ÍXV_ÅÌlÅ·¡</li> +<li>ÃÞ°ÀÍÞ°½ÌXVpxÍ1ÔÉ1ñŤڽ¥¨¢¥³ÍXV_ÅÌlÅ·¡</li> </uL> <?php } ?> <?php if ($errors) { ?>