상속: extends think\Cache
예제 #1
0
 public function testMemcached()
 {
     $test = Memcached::getInstance();
     //$test->set ( 'test', 12354, 30 );
     var_dump($test->get('test'));
     // 赋值 缓存
     // 移除缓存
     //	$memcached->rm ( 'test' );
     // 清空缓存
     //	$memcached->clear ();
 }
예제 #2
0
 public function mem()
 {
     $mem = Memcached::getInstance();
     $tags = $mem->get('tags');
     dump($tags);
     if (!$tags) {
         $mem->set('tags', M('tag')->select());
     }
     dump($mem->get('tags'));
     //        $mem = Memcached::getInstance();
     //        $mem->set('ls', 'liushuai');
     //        echo $mem->get('ls');
     //        dump($mem);
     //        $Cache = Cache::getInstance('memcache');
     //////或者:
     ////        $options = array('host' => '127.0.0.1', 'port' => 11211, 'timeout' => 10,
     ////            'persistent' => false);
     ////        $Cache = Cache::getInstance('memcache', $options);
     //        $Cache->set('name','ThinkPHP'); // 缓存name数据
     //        $value = $Cache->get('name'); // 获取缓存的name数据
     //        $Cache->close();
     //        echo $value;
 }
예제 #3
0
 public function test()
 {
     var_dump(C('MEMCACHE_HOST'));
     var_dump(C('options'));
     $relpy_data = $this->set_reply_data();
     foreach ($relpy_data['A'] as $key => $value) {
         var_dump($value['key']);
     }
     $mc = S('ss', '22');
     $mc1 = S('ss');
     var_dump($mc1);
     $memcache = Memcached::getInstance();
     //$memcache = new Memcache ();
     $memcache_key = 1;
     $memcache->set($memcache_key, '2');
     var_dump($memcache->get($memcache_key));
     if (!$memcache->get($memcache_key)) {
         // 			foreach ( $relpy_data ['A'] as $key => $value ) {
         // 				if (! strstr ( $rev_content, $value ['key'] )) {
         // 					// 检索到了
         // 					$this->wchat_obj->text ( $value ['value'] )->reply ();
         // 					$memcache->set ( $memcache_key, $value ['next'] );
         // 					exit ();
         // 				}
         // 			}
         var_dump('sdd');
     } else {
         $position = $memcache->get($memcache_key);
         // 			foreach ( $relpy_data [$position] as $key => $value ) {
         // 				if (! strstr ( $rev_content, $value ['key'] )) {
         // 					// 检索到了
         // 					$this->wchat_obj->text ( $value ['value'] )->reply ();
         // 					$memcache->set ( $memcache_key, $value ['next'] );
         // 					exit ();
         // 				}
         // 			}
         var_dump('sdd11');
     }
 }
예제 #4
0
 public function j_register()
 {
     if (!isset($_POST['mem']) && !isset($_POST['myh']) && !isset($_POST['myz']) && !isset($_POST['mp1']) && !isset($_POST['mp2'])) {
         Response::show('-100', '注册信息丢失!');
     }
     // 验证码
     $checkcode = strtolower($_POST['myz']);
     // 用户的邮箱
     $email = $_POST['mem'];
     $Memcached = Memcached::getInstance();
     // 暂时不加密了。
     if ($Memcached->get($email) == $checkcode) {
         // 验证码正确
         // 注册用户信息封装
         $account_info = null;
         $account_info['account_id'] = $_POST['mem'];
         $account_info['account_name'] = $_POST['myh'];
         $account_info['password'] = xw_md5($_POST['mp1']);
         $model = M();
         $model->startTrans();
         $account_model = D('Account');
         if ($account_model->find($account_info['account_id'])) {
             Response::show('-100', '用户已经存在!');
         }
         if ($account_model->add_account($account_info)) {
             $model->commit();
             Response::show('200', '注册成功!');
         } else {
             $model->rollback();
             Response::show('-100', '注册失败!');
         }
     } else {
         Response::show('-100', '验证码不正确!');
     }
 }