コード例 #1
0
ファイル: MyRedis.php プロジェクト: panchao1/my_php_code
 public static function instance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
ファイル: MyRedis.class.php プロジェクト: lughong/test
 protected function getConfig()
 {
     //配置
     if (!self::$config) {
         self::$config = (include REDIS_PATH . "config/config.php");
     }
 }
コード例 #3
0
ファイル: MyRedis.php プロジェクト: sdgdsffdsfff/dagger_alarm
 private static function slaveInstance($host = REDIS_DEFAULT_PRODUCT_SLAVE_HOST, $port = REDIS_DEFAULT_PRODUCT_SLAVE_PORT)
 {
     if (!self::$slave) {
         self::$slave = new parent($host, $port);
     }
     return self::$slave;
 }
コード例 #4
0
ファイル: IdentifyCode.class.php プロジェクト: skyshow/ticket
 public static function identifyCode($phone, $code, $type = 0)
 {
     $memCode = MyRedis::get("identifyCode.pub:{$type}:{$phone}");
     if ($memCode != 0 && $memCode == $code) {
         return true;
     }
     return false;
 }
コード例 #5
0
ファイル: Cache.class.php プロジェクト: lughong/test
 public static function set($key_footer = null, $data = array())
 {
     if (self::$_redis) {
         //开启了redis缓存
         return MyRedis::set($key_footer, $data);
     } elseif (self::$_memcache) {
         //开启了memcache缓存
         return MyMemcache::set($key_footer, $data);
     } else {
         return false;
     }
 }
コード例 #6
0
 public function waterfall()
 {
     $sid = intval($_GET['sub_mid']);
     $pageId = max(intval($_GET['page']), 1);
     $limit = 10;
     $start = ($pageId - 1) * $limit;
     $stop = $start + $limit;
     $submoduleDB = new SubmoduleModelDB();
     $submodule = $submoduleDB->getRow('SELECT mid, code FROM `' . $submoduleDB->getTableName() . '` WHERE id=?', array(intval($sid)));
     $details = MyRedis::getSubmoduleDetail($submodule, $start, $stop);
     Common::debug($details);
     foreach ($details['messages'] as $key => $value) {
         if ($tmp = unserialize($value)) {
             $value = array_map('urldecode', array_map('htmlspecialchars', $tmp));
             // $detail = date('[Y-m-d H:i:s] ', $time)."{$submodule['name']} 错误号:{$submodule['code']} 详细:{$message}, 邮件:第{$mailMsgCount}次,短信:第{$smsMsgCount}次,来自{$client_ip}/{$onlineip},xhprofId[{$xhprofId}]";
             $details['messages'][$key] = date('[Y-m-d H:i:s] ', $value['time']) . "{$value['name']} 错误号:{$value['code']},脚本:{$value['script']},详细:{$value['message']},来自{$value['clientIp']}/{$value['serverIp']}";
         } else {
             $details['messages'][$key] = htmlspecialchars($value);
         }
     }
     Message::showSucc('详细信息', $details['messages']);
 }
コード例 #7
0
 public function export()
 {
     //http://admin.alarm.mix.sina.com.cn/?s=redis_tmp_log&a=get_tmp_log&_search_field=type&_search_keyword=1
     $type = $_GET['_search_keyword'];
     $fileName = "{$type}.txt";
     header("Cache-Control:public");
     header("Pragma:public");
     header("Content-type:APPLICATION/OCTET-STREAM");
     header("Content-Disposition:inline; filename={$fileName}");
     $i = 0;
     $limit = 100;
     while (true) {
         $start = (++$i - 1) * $limit;
         $stop = $start + $limit;
         $tmpLog = MyRedis::getTmpLog($type, $start, $stop);
         if (empty($tmpLog['messages'])) {
             break;
         }
         ob_start();
         echo implode("\n", $tmpLog['messages']);
         ob_end_flush();
     }
 }
コード例 #8
0
 public function getDetail()
 {
     $pid = intval($_GET['pid']);
     if (!$pid) {
         $projectDB = new ProjectModelDB();
         $pid = $projectDB->getFirst('SELECT id FROM `' . $projectDB->getTableName() . '` WHERE name=?', array($_GET['pname']));
     }
     $pageId = max(intval($_GET['page']), 1);
     $limit = 50;
     $start = ($pageId - 1) * $limit;
     $stop = $start + $limit;
     $detail = MyRedis::getProjectDetail($pid, $start, $stop);
     $data = array();
     foreach ($detail['messages'] as $i => $v) {
         if (($msg = @unserialize($v)) && is_array($msg)) {
             $data[$i] = $msg;
         } else {
             $msg = explode(" ", $v);
             $data[$i]['time'] = str_replace(array('[', ']'), '', array_shift($msg) . ' ' . array_shift($msg));
             $data[$i]['name'] = array_shift($msg);
             $data[$i]['code'] = str_replace(array("错误号:", '{', '}'), '', array_shift($msg));
             $otherMsg = array_pop($msg);
             $otherMsgArr = explode(",", $otherMsg);
             if (count($otherMsgArr) == 4) {
                 $data[$i]['xhprofId'] = str_replace(array('xhprofId[', ']'), '', array_pop($otherMsgArr));
             }
             list($data[$i]['clientIp'], $data[$i]['serverIp']) = explode("/", str_replace(array("来自"), '', array_pop($otherMsgArr)));
             $data[$i]['email'] = str_replace(array("短信:", '第', '次'), '', array_pop($otherMsgArr));
             $data[$i]['sms'] = str_replace(array("邮件:", '第', '次'), '', array_pop($otherMsgArr));
             $data[$i]['message'] = str_replace(array("详细:"), '', implode(" ", $msg));
         }
     }
     Common::debug($data, 'Result');
     $pageModel = new Page($detail['count'], $limit);
     $this->setView('pageTitle', '详细信息');
     $this->setView('data', $data);
     $this->setView('pageStr', $pageModel->getPageStr());
     $this->display('Detail.html');
 }
コード例 #9
0
ファイル: example.php プロジェクト: sdgdsffdsfff/dagger_alarm
<?php

/**
 * @Copyright (c) 2011, 新浪网运营部-网络应用开发部
 * All rights reserved.
 * 示例程序
 * @author          wangxin <*****@*****.**>
 * @time            2011/3/2 15:03
 * @version         Id: 0.9
*/
require dirname(__FILE__) . "/global.php";
MyRedis::test();
コード例 #10
0
ファイル: SMSService.class.php プロジェクト: skyshow/ticket
 /**
  * 获取某个手机号某种业务类型在一定时间内发送的次数,并加一
  * @param $phone          手机号码
  * @param $codetype       业务类型:0-注册帐号 1-发送验证码到旧绑定手机 2-更换绑定手机 3-提现 4-重置密码
  * @return int
  */
 private static function updateSendNums($phone, $codetype)
 {
     $num = 0;
     if (MyRedis::exists("identifyCode:num:{$codetype}:{$phone}")) {
         $num = intval(MyRedis::get("identifyCode:num:{$codetype}:{$phone}"));
     }
     $expire = 3 * 60;
     // 统计3分钟内的点击次数
     MyRedis::set("identifyCode:num:{$codetype}:{$phone}", $num + 1, $expire);
     // 次数加1
     return $num;
 }
コード例 #11
0
ファイル: form.php プロジェクト: guiguoershao/my_redis_tool
                }
                $data[$key][$arr[0]] = $arr[1];
            }
            break;
        case 3:
            $array = explode('|', $data[$key]);
            foreach ($array as $k => $v) {
                $data[$key + $k] = $v;
            }
            $data = array_values($data);
            break;
    }
}
$connect = $_SESSION['connect'];
$return['number'] = (count($data) + 1) * 2 >= 10 ? 12 : 12 - (count($data) + 1) * 2;
$myredis = new MyRedis($connect);
$result = $myredis->getResult($instruction, $data);
$error = $system_config['instruction_output'][$instruction]['error'];
switch ($system_config['instruction_output'][$instruction]['type']) {
    case 'boolean':
        if ($result !== true) {
            $return['info'] = empty($error) ? $result : $error;
            break;
        }
        $return['status'] = 1;
        $return['info'] = empty($error) ? $result : $error;
        break;
    case 'string':
        if ($result === false || $result === 'nil' || empty($result)) {
            $return['info'] = empty($error) ? $result : $error;
            break;
コード例 #12
0
ファイル: redist.php プロジェクト: lughong/shop
 public function buying()
 {
     //设置抢购规则
     //抢购时间为20分钟,到时不能再抢购
     //抢购数量为1000,抢完不能再抢购
     //给用户随机分配一个数字,最后是否抢购成功就看这个数是否是6的倍数
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $mem = MyRedis::connect($ip);
     $surplus = $mem->get('buying_goods_num');
     //是否已经过了抢购时间
     if ($surplus !== false) {
         //是否已经被抢光了
         if ($surplus > 0) {
             //判断之前是否已经抢购了
             // $uid = LuS::get( 'uid' );
             $uid = mt_rand(1, 100000);
             //测试随机生成一个uid,正式使用时请使用正确的uid
             $is_exists = $mem->sismember('buying_user', $uid);
             //判断是否已经抢购到了
             if (!$is_exists) {
                 $number = $this->getrand();
                 if ($number == 2) {
                     $mem->decr('buying_goods_num');
                     $mem->sadd('buying_user', $uid);
                     //抢购成功
                     $url = url('rand', 'rand::successbuying');
                     header('Location:' . $url);
                     throw new Exception('exit');
                 }
             } else {
                 //已经抢购成功
                 $url = url('rand', 'rand::successbuying', 1);
                 header('Location:' . $url);
                 throw new Exception('exit');
             }
         } else {
             //数量被抢购一空
             $url = url('rand', 'rand::nonumbuying');
             header('Location:' . $url);
             throw new Exception('exit');
         }
     } else {
         //已经过了抢购时间
         $url = url('rand', 'rand::notimebuying');
         header('Location:' . $url);
         throw new Exception('exit');
     }
 }
コード例 #13
0
ファイル: 1.php プロジェクト: az0ne/diaoyu
<?php

include 'global.php';
$rs = MyRedis::getInstance();
$mc = new MyMemcache();
$mc->set('a', array(1, 2, 3));
$rs->set('a', array(1, 2, 3));
print_r($rs->get('a'));
print_r($mc->get('a'));