/** * 清空缓存 */ function sp_clear_cache() { import("ORG.Util.Dir"); $dirs = array(); // runtime/ $rootdirs = scandir(RUNTIME_PATH); //$noneed_clear=array(".","..","Data"); $noneed_clear = array(".", ".."); $rootdirs = array_diff($rootdirs, $noneed_clear); foreach ($rootdirs as $dir) { if ($dir != "." && $dir != "..") { $dir = RUNTIME_PATH . $dir; if (is_dir($dir)) { array_push($dirs, $dir); $tmprootdirs = scandir($dir); foreach ($tmprootdirs as $tdir) { if ($tdir != "." && $tdir != "..") { $tdir = $dir . '/' . $tdir; if (is_dir($tdir)) { array_push($dirs, $tdir); } } } } else { @unlink($dir); } } } $dirtool = new Dir(""); foreach ($dirs as $dir) { $dirtool->del($dir); } if (defined('IS_SAE') && IS_SAE) { $global_mc = @memcache_init(); if ($global_mc) { $global_mc->flush(); } $no_need_delete = array("THINKCMF_DYNAMIC_CONFIG"); $kv = new SaeKV(); // 初始化KVClient对象 $ret = $kv->init(); // 循环获取所有key-values $ret = $kv->pkrget('', 100); while (true) { foreach ($ret as $key => $value) { if (!in_array($key, $no_need_delete)) { $kv->delete($key); } } end($ret); $start_key = key($ret); $i = count($ret); if ($i < 100) { break; } $ret = $kv->pkrget('', 100, $start_key); } } }
function deleteChess() { $kv = new SaeKV(); $kv->init(); $ret = $kv->pkrget('chess_', 100); foreach ($ret as $key => $value) { $ret = $kv->delete('chess_' . $value['s']); } }
public function DelCookie($id) { if (!test_user()) { echo json_encode(array('error' => '删除失败', 'status' => false)); return; } if (M('Cookie')->where('id=%d', $id)->delete()) { M('SignList')->where('cookieid=%d', $id)->delete(); $kv = new \SaeKV(); $kv->init(); $kv->delete('Cookie' . $id); echo json_encode(array('info' => '删除成功', 'status' => true)); } else { echo json_encode(array('error' => '删除失败', 'status' => false)); } }
function clearkvfolder($folder) { //data/template $kv = new SaeKV(); $kv->init(); $ret = $kv->pkrget($folder, 100); while (true) { foreach ($ret as $k => $v) { $kv->delete($k); } $start_key = $k; $i = count($ret); if ($i < 100) { break; } $ret = $kv->pkrget($folder, 100, $start_key); } }
public function kv() { $k = new SaeKV(); $k->init(); $k->set('a', 'aaa'); //建立一条字符串数据 $ret = $k->get('a'); //获得a的值 dump($ret); $k->set('b', array('a', 'b', 'c')); //可存储数组或对象 $ret = $k->get("b"); //获得b的值 dump($ret); $k->delete("a"); //删除a }
public function ClearSignStatus() { $cookieArr = M('Cookie')->where('overdue=0')->select(); // 查询是否过期 foreach ($cookieArr as $value) { // 双重查询确认 if (GetTbName('BDUSS=' . $value['cookies'] . ';') == false && GetTbName('BDUSS=' . $value['cookies'] . ';') == false) { // 标记过期 M('Cookie')->where('id=%d', $value['id'])->setField('overdue', 1); // 删除Cookie缓存 $kv = new \SaeKV(); $kv->init(); $cookies = $kv->delete('Cookie' . $value['id']); // 删除该Cookie的贴吧 M('SignList')->where('cookieid=%d', $value['id'])->delete(); $email = M('User')->where('username="******"', $value['username'])->getField('email'); // 通知用户 send_mail($email, '【C云签】您的百度账户Cookie已失效', '您的百度账户【' . $value['name'] . '】Cookie已失效,请到 http://signtb.sinaapp.com 查看与重置'); } } M('SignList')->where('id>0')->setField('issign', 0); }
function do_cos_html_cache_action() { if ($_POST['indexHtmlCacheDelbt']) { $kv = new SaeKV(); $kv->init(); $ret = $kv->get(CosSiteHome . '/index.html'); if ($ret) { if ($kv->delete(CosSiteHome . '/index.html')) { $msg = __('Index Caches were deleted successfully', 'cosbeta'); } else { $msg = '存在首页缓存,但是删除失败'; } } else { $msg = '不存在首页缓存'; } } if (!empty($_POST['htmlCacheDelbt'])) { // @rename(CosBlogPath."index.html",CosBlogPath."index.bak"); // @chmod( CosBlogPath."index.bak", 0666 ); $kv = new SaeKV(); $kv->init(); $ret = $kv->get(CosSiteHome . '/index.html'); if ($ret) { //$kv->set(CosBlogPath.'index.bak',$ret); $kv->delete(CosSiteHome . '/index.html'); } global $wpdb; if ($_POST['cache_id'] * 1 > 0) { //delete cache by id DelCacheByUrl(get_permalink($_POST['cache_id'])); $msg = __('the post cache was deleted successfully: ID=', 'cosbeta') . $_POST['cache_id']; } else { if (strlen($_POST['cache_id']) > 2) { $postRes = $wpdb->get_results("SELECT `ID` FROM `" . $wpdb->posts . "` WHERE post_title like '%" . $_POST['cache_id'] . "%' LIMIT 0,1 "); DelCacheByUrl(get_permalink($postRes[0]->ID)); $msg = __('the post cache was deleted successfully: Title=', 'cosbeta') . $_POST['cache_id']; } else { $postRes = $wpdb->get_results("SELECT `ID` FROM `" . $wpdb->posts . "` WHERE post_status = 'publish' AND ( post_type='post' OR post_type='page' ) ORDER BY post_modified DESC "); foreach ($postRes as $post) { DelCacheByUrl(get_permalink($post->ID)); } $msg = __('HTML Caches were deleted successfully', 'cosbeta'); } } } if ($msg) { echo '<div class="updated"><strong><p>' . $msg . '</p></strong></div>'; } }
/** * Remove an item from the cache. * * @param string $key * @return void */ public function forget($key) { $this->kvdb->delete($this->prefix . $key); }
<?php if (!empty($k)) { $v = file_get_contents('saekv://' . $k); if ($v) { echo "<p>取值成功:{$k} => <pre style=\"margin:5px;border:1px solid #CCC;\">" . htmlspecialchars($v) . "</pre></p>"; } else { echo "<p>{$k}不存在!</p>"; } } } else { if ($a == 'del') { $kv = new SaeKV(); $ret = $kv->init(); if (!empty($k)) { $v = $kv->delete($k); echo "<p>saekv://{$k}删除成功!</p>"; } else { if (!empty($_GET['k'])) { $v = $kv->delete($_GET['k']); echo "<p>saekv://{$_GET['k']}删除成功!</p>"; } else { ?> <form action="saekv.php?a=del" name="setform" method="post"> <p> saekv://<input type="text" name="k" value="" /></p> <p> <input type="submit" value="删除" /></p> </form> <?php } }
/** * Clear the kvdb on sae with the prefix * * @param string The prefix * @return void * */ function clear_skincache($pre) { $kv = new SaeKV(); $kv->init(); $ret = $kv->pkrget($pre, 100); if (empty($ret)) { return false; } foreach ($ret as $key => $value) { $kv->delete($key); } unset($kv); ET::$cache->remove(ET::$cache->fname_key); return true; }