本文整理汇总了PHP中memory函数的典型用法代码示例。如果您正苦于以下问题:PHP memory函数的具体用法?PHP memory怎么用?PHP memory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
global $_G;
$id = intval($_GET['id']);
if (!$id) {
msg('抱歉,ID不存在');
return false;
}
$cache_name = 'img_' . $id;
$cache = memory('get', $cache_name);
if (is_array($cache)) {
$img = $cache;
} else {
$img = D(array('and' => ' AND id = ' . $id, 'table' => __CLASS__));
if (!$img[id]) {
msg('抱歉,当前信息不存在');
return false;
}
DB::update('img', array('like' => $img[like] + 1), 'id=' . $id);
$up = D(array('and' => ' AND id <' . $id, 'table' => __CLASS__, 'order' => 'id DESC'));
$down = D(array('and' => ' AND id >' . $id, 'table' => __CLASS__, 'order' => 'id ASC'));
$img[up] = $up[id] ? '<a href="' . $up[url] . '">' . $up[title] . '</a>' : '没有了';
$img[down] = $down[id] ? '<a href="' . $down[url] . '">' . $down[title] . '</a>' : '没有了';
// $img[message] = preg_replace("/###\{(.*?)\}###/ies","parse_img_goods('\\1')",$img[message]);
//$img[message] = preg_replace("/###\{(.*?)\}###/ies","parse('img_goods','\\1')",$img[message]);
memory('set', $cache_name, $img);
}
$this->add(array('img' => $img));
seo($img['title'], $img['keywords'], $img['description']);
$this->show();
}
示例2: global_header_mobile
function global_header_mobile()
{
global $_G, $show_message;
function dsu_signtz()
{
dheader('Location: plugin.php?id=dsu_paulsign:sign&mobile=yes');
}
$var = $_G['cache']['plugin']['dsu_paulsign'];
if (defined('IN_dsu_paulsign') || $show_message || defined('IN_dsu_paulsc') || !$_G['uid'] || !$var['ifopen'] || !$var['wap_sign']) {
return '';
}
$tdtime = gmmktime(0, 0, 0, dgmdate($_G['timestamp'], 'n', $var['tos']), dgmdate($_G['timestamp'], 'j', $var['tos']), dgmdate($_G['timestamp'], 'Y', $var['tos'])) - $var['tos'] * 3600;
$allowmem = memory('check');
if ($var['ftopen'] && in_array($_G['groupid'], unserialize($var['tzgroupid'])) && !in_array($_G['uid'], explode(",", $var['ban'])) && in_array($_G['groupid'], unserialize($var['groups']))) {
if ($allowmem && $var['mcacheopen']) {
$signtime = memory('get', 'dsu_pualsign_' . $_G['uid']);
}
if (!$signtime) {
$qiandaodb = DB::fetch_first("SELECT time FROM " . DB::table('dsu_paulsign') . " WHERE uid='{$_G['uid']}'");
$signtime = $qiandaodb['time'];
$htime = dgmdate($_G['timestamp'], 'H', $var['tos']);
if ($qiandaodb) {
if ($allowmem && $var['mcacheopen']) {
memory('set', 'dsu_pualsign_' . $_G['uid'], $qiandaodb['time'], 86400);
}
if ($qiandaodb['time'] < $tdtime) {
if ($var['timeopen']) {
if (!($htime < $var['stime']) && !($htime > $var['ftime'])) {
return dsu_signtz();
}
} else {
return dsu_signtz();
}
}
} else {
$ttps = DB::fetch_first("SELECT posts FROM " . DB::table('common_member_count') . " WHERE uid='{$_G['uid']}'");
if ($var['mintdpost'] <= $ttps['posts']) {
if ($var['timeopen']) {
if (!($htime < $var['stime']) && !($htime > $var['ftime'])) {
return dsu_signtz();
}
} else {
return dsu_signtz();
}
}
}
} else {
if ($signtime < $tdtime) {
if ($var['timeopen']) {
if (!($htime < $var['stime']) && !($htime > $var['ftime'])) {
return dsu_signtz();
}
} else {
return dsu_signtz();
}
}
}
}
return '<a href="plugin.php?id=dsu_paulsign:sign">' . lang('plugin/dsu_paulsign', 'name') . '</a>';
}
示例3: __construct
public function __construct()
{
$this->_table = 'pre_common_basedata';
$this->_allowmem = memory('check');
$this->_cache_ttl = 86400;
parent::__construct();
}
示例4: main
function main()
{
global $_G;
$id = intval($_GET['id']);
if ($id < 1) {
msg('ID不存在');
return false;
}
$cache_name = 'article_' . $id;
$cache = memory('get', $cache_name);
if (is_array($cache)) {
$article = $cache;
} else {
$article = D(array('table' => 'article', 'and' => ' id = ' . $id . ' AND `hide`=0 '));
if (!$article[id]) {
msg('抱歉,当前文章不存在或未审核');
}
$up = D(array('and' => ' AND id <' . $id, 'table' => __CLASS__, 'order' => 'id DESC'));
$down = D(array('and' => ' AND id >' . $id, 'table' => __CLASS__, 'order' => 'id ASC'));
$article[up] = $up[id] ? '<a href="' . $up[id_url] . '">' . $up[title] . '</a>' : '没有了';
$article[down] = $down[id] ? '<a href="' . $down[id_url] . '">' . $down[title] . '</a>' : '没有了';
save_history(__CLASS__, $article[id]);
DB::update('article', array('views' => $article[views] + 1), 'id=' . $article[id]);
memory('set', $cache_name, $article);
}
$this->add(array('article' => $article));
seo($article['title'], $article['keywords'], $article['description']);
$this->show($article['tpl']);
}
示例5: _getBaseInfo
protected function _getBaseInfo()
{
global $_G;
$info = array();
loadcache(array('userstats', 'historyposts'));
$indexData = memory('get', 'forum_index_page_1');
if (is_array($indexData) && $indexData) {
$indexData = array();
$info['threads'] = $indexData['threads'] ? $indexData['threads'] : 0;
$info['todayPosts'] = $indexData['todayposts'] ? $indexData['todayposts'] : 0;
$info['allPosts'] = $indexData['posts'] ? $indexData['posts'] : 0;
} else {
$threads = $posts = $todayposts = 0;
$query = C::t('forum_forum')->fetch_all_by_status(1, 0);
foreach ($query as $forum) {
if ($forum['type'] != 'group') {
$threads += $forum['threads'];
$posts += $forum['posts'];
$todayposts += $forum['todayposts'];
}
}
$info['threads'] = $threads ? $threads : 0;
$info['allPosts'] = $posts ? $posts : 0;
$info['todayPosts'] = $todayposts ? $todayposts : 0;
}
$info['members'] = $_G['cache']['userstats']['totalmembers'] ? intval($_G['cache']['userstats']['totalmembers']) : 0;
$postdata = $_G['cache']['historyposts'] ? explode("\t", $_G['cache']['historyposts']) : array(0, 0);
$info['yesterdayPosts'] = intval($postdata[0]);
return $info;
}
示例6: __construct
public function __construct()
{
$this->_table = 'common_member_forum_buylog';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member';
$this->_allowmem = memory('check');
$this->_cache_ttl = 86400;
parent::__construct();
}
示例7: __construct
public function __construct()
{
$this->_table = 'common_session';
$this->_pk = 'sid';
$this->_pre_cache_key = 'common_session_';
$this->_allowmem = memory('check');
$this->_cache_ttl = 120;
parent::__construct();
}
示例8: fetch_all_by_g_id
public static function fetch_all_by_g_id()
{
$data = memory('get', 'plugin_dsuamupperc_fetch_all_by_g_id');
if ($data) {
return $data;
}
$result = DB::fetch_all("SELECT * FROM %t WHERE id>%d LIMIT %d", array('plugin_dsuamupperc', '-1', '100'), 'id');
memory('set', 'plugin_dsuamupperc_fetch_all_by_g_id', $result, 60);
return $result;
}
示例9: delete
public function delete($val, $unbuffered = false)
{
if ($val = dintval($val, true)) {
$this->_pre_cache_key = 'blockstylecache_';
$this->_cache_ttl = getglobal('setting/memory/diyblock/ttl');
$this->_allowmem = getglobal('setting/memory/diyblock/enable') && memory('check');
return parent::delete($val, $unbuffered);
}
return false;
}
示例10: member
private function member($groups = array()){
$cachekey = 'reply_robots_members';
$members = unserialize(memory('get',$cachekey));
if(is_array($members)){
return $members[array_rand($members)];
}else{
$members = DB::fetch_all("SELECT uid,username FROM ".DB::table('common_member')." WHERE `groupid` IN ({$groups}) LIMIT 100");
memory('set',$cachekey,serialize($members),86400);
return $members[array_rand($members)];
}
}
示例11: cache
function cache()
{
global $_G;
if ($_GET['onsubmit'] && check()) {
if ($_GET[postdb][system_cache] == 1) {
memory('clear');
loadcache($_G[_config][cache_list], 'update');
}
api_post(array('m' => 'cache', 'a' => 'update', 'cache_list' => implode(',', $_G[_config][cache_list])));
remove_dir('web/templates_c/');
cpmsg('更新成功', 'success', 'm=tools&a=cache');
return false;
}
$this->show('tools/cache');
}
示例12: _process_cmd_memory
private static function _process_cmd_memory($cmd, $name, $ttl = 0)
{
$ret = '';
switch ($cmd) {
case 'set':
$ret = memory('set', 'process_lock_' . $name, time(), $ttl);
break;
case 'get':
$ret = memory('get', 'process_lock_' . $name);
break;
case 'rm':
$ret = memory('rm', 'process_lock_' . $name);
}
return $ret;
}
示例13: count_by_lasttime
public function count_by_lasttime($lasttime, $glu = '>=')
{
$lasttime = intval($lasttime);
if (empty($lasttime) || !in_array('>=', '>', '<', '<=')) {
return 0;
}
$mem_key = 'plugin_dsuamupper::count_by_lasttime' . $lasttime . $glu;
$data = memory('get', $mem_key);
if ($data) {
return $data;
}
$result = DB::result_first("SELECT COUNT(*) FROM " . $this->_table . " WHERE lasttime {$glu} {$lasttime}");
memory('set', $mem_key, $result);
return $result;
}
示例14: block_getstyle
function block_getstyle($styleids = array())
{
global $_G;
static $allowmem = null, $cachettl = null;
if ($allowmem === null) {
$allowmem = ($cachettl = getglobal('setting/memory/diyblock')) !== null && memory('check');
}
$pre = 'blockstyle_';
if ($ret = $styleids && !is_array($styleids) ? $styleids : false) {
if ($_G[$pre . $ret]) {
return $_G[$pre . $ret];
} else {
$styleids = (array) $styleids;
}
}
$cacheprekey = 'blockstylecache_';
$styleids = array_map('intval', $styleids);
$styleids = array_unique($styleids);
if ($styleids) {
if ($allowmem) {
if (($cachedata = memory('get', $styleids, $cacheprekey)) !== false) {
foreach ($cachedata as $styleid => $style) {
$_G[$pre . $styleid] = $style;
}
if (!($styleids = array_diff($styleids, array_keys($cachedata)))) {
return $ret ? $_G[$pre . $ret] : true;
}
}
}
if ($styleids) {
foreach (C::t('common_block_style')->fetch_all($styleids) as $styleid => $value) {
$value['template'] = !empty($value['template']) ? (array) dunserialize($value['template']) : array();
$value['fields'] = !empty($value['fields']) ? (array) dunserialize($value['fields']) : array();
$_G[$pre . $styleid] = $value;
if ($allowmem) {
memory('set', $cacheprekey . $styleid, $_G[$pre . $styleid], $cachettl);
}
}
}
return $ret ? $_G[$pre . $ret] : true;
}
return array();
}
示例15: _process_cmd_memory
function _process_cmd_memory($cmd, $name, $ttl = 0)
{
return memory($cmd, 'process_lock_' . $name, time(), $ttl);
}