本文整理汇总了PHP中base_kvstore::config_persistent方法的典型用法代码示例。如果您正苦于以下问题:PHP base_kvstore::config_persistent方法的具体用法?PHP base_kvstore::config_persistent怎么用?PHP base_kvstore::config_persistent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base_kvstore
的用法示例。
在下文中一共展示了base_kvstore::config_persistent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: command_kvrecovery
function command_kvrecovery($instance = null)
{
if (!is_null($instance) && !defined('FORCE_KVSTORE_STORAGE')) {
$instance = trim($instance);
if (!(strpos($instance, '_') === 0)) {
$instance = 'base_kvstore_' . $instance;
}
define('FORCE_KVSTORE_STORAGE', $instance);
}
base_kvstore::config_persistent(false);
$testObj = base_kvstore::instance('test');
if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
kernel::log('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
exit;
}
kernel::log('KVstore Recovery...');
$db = kernel::database();
$count = $db->count('SELECT count(*) AS count FROM sdb_base_kvstore', true);
if (empty($count)) {
kernel::log('No data recovery');
exit;
}
$pagesize = 100;
$page = ceil($count / 100);
for ($i = 0; $i < $page; $i++) {
$rows = $db->selectlimit('SELECT * FROM sdb_base_kvstore', $pagesize, $i * $pagesize);
foreach ($rows as $row) {
//kernel::log($row['key']);continue;
$row['value'] = unserialize($row['value']);
//todo:合法数据
if (base_kvstore::instance($row['prefix'])->recovery($row)) {
kernel::log($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Success');
} else {
kernel::log($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Failure');
}
}
}
}
示例2: command_kvrecovery
public function command_kvrecovery($instance = null)
{
if (app::get('base')->status() == 'uninstalled') {
logger::info('系统未安装!请先运行install');
return;
}
base_kvstore::config_persistent(false);
//临时禁用KV持久化 TODO 比较危险
$testObj = base_kvstore::instance('test');
if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
logger::info('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
exit;
}
logger::info('KVrecovery BEGIN...');
$db = vmc::database();
$count = $db->count('SELECT count(*) AS count FROM vmc_base_kvstore', true);
if (empty($count)) {
logger::info('No data recovery');
exit;
}
$pagesize = 100;
$page = ceil($count / 100);
for ($i = 0; $i < $page; $i++) {
$rows = $db->selectlimit('SELECT * FROM vmc_base_kvstore', $pagesize, $i * $pagesize);
foreach ($rows as $row) {
$arr_value = unserialize($row['value']);
if (!$arr_value || !is_array($arr_value)) {
logger::error($row['prefix'] . '=>' . $row['key'] . ' ... KVrecovery ERROR');
}
$row['value'] = $arr_value;
if (base_kvstore::instance($row['prefix'])->recovery($row)) {
logger::info($row['prefix'] . '=>' . $row['key'] . ' ... KVrecovery Success');
} else {
logger::warning($row['prefix'] . '=>' . $row['key'] . ' ... KVrcovery Failure');
}
}
}
logger::info('KVrecovery END...');
}
示例3: command_kvrecovery
function command_kvrecovery($instance = null)
{
if (!is_null($instance)) {
$instance = trim($instance);
if (!(strpos($instance, '_') === 0)) {
$instance = 'base_kvstore_' . $instance;
}
config::set('kvstore.default', $instance);
}
base_kvstore::config_persistent(false);
$testObj = base_kvstore::instance('test');
if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
logger::info('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
exit;
}
logger::info('KVstore Recovery...');
$db = app::get('base')->database();
$count = $db->executeQuery('SELECT count(*) AS count FROM base_kvstore')->fetchColumn();
if (!$count) {
logger::info('No data recovery');
exit;
}
$pagesize = 100;
$page = ceil($count / 100);
for ($i = 0; $i < $page; $i++) {
$rows = $db->executeQuery('SELECT * FROM base_kvstore limit ? offset ?', [$pagesize, $pagesize * $i])->fetchAll();
foreach ($rows as $row) {
//logger::info($row['key']);continue;
$row['value'] = unserialize($row['value']);
//todo:合法数据
if (base_kvstore::instance($row['prefix'])->recovery($row)) {
logger::info($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Success');
} else {
logger::info($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Failure');
}
}
}
}