安装说明
mkdir php_httpsqs_client? cd php_httpsqs_client?
unzip php_httpsqs_0.1.zip? /usr/local/php/bin/phpize? ./configure --enable-httpsqs
--with-php-config=/usr/local/php/bin/php-config? make && make install?
#接着在php.ini中添加一行? extension=httpsqs.so;
函数说明
/**? ?* 创建httpsqs连接? ?* @param string $host 服务器地址,可以为空,默认为127.0.0.1? ?* @param int ? ?$port 服务器端口,可以为空,默认为1218? ?* @return resource? ?*/? $hr = httpsqs_connect("127.0.0.1", 1218);
/**? ?* 写入队列数据? ?* @param resource $hr ? ? ?服务器连接句柄? ?* @param string ? $queue ? 队列名称? ?* @param string ? $data ? ?写入数据? ?* @param string ? $charset 字符集,可以为空,默认为utf-8? ?* @return boolean? ?*/?
$putRes = httpsqs_put($hr, "testQueue", "This is a test Data", "UTF-8");/** ? ?* 获取队列最后一条数据? ?* @param resource $hr? ?* @param string ? $queue? ?* @param boolean ?$return_array 是否返回数组,可以为空,默认为false? ? ? ? ? ? 返回数组格式:array('pos'=>'队列插入点', 'data'=>'数据值')? ?* @param string ? $charset 可以为空? ?* @return mixed? ?*/? $content = httpsqs_get($hr, "testQueue", true, "UTF-8");
/**? ?* 获取队列状态? ?* @param resource $hr? ?* @param string ? $queue? ?* @param boolean ?$return_json 是否返回状态的json格式,可以为空,默认为false? ?* @return string? ?*/? $status = httpsqs_status($hr, "testQueue", true);
/**? ?* 获取队列某个点数据? ?* @param resource $hr? ?* @param string ? $queue? ?* @param int ? ? ?$pos 要获取的某条数据的位置? ?* @param string ? $charset 可以为空? ?* @return string? ?*/? $posData = httpsqs_view($hr, "testQueue", 10, "UTF-8");
/**? ?* 队列重置? ?* @param resource $hr? ?* @param string ? $queue? ?* @return boolean? ?*/? $resetRes = httpsqs_reset($hr, "testQueue");
/**? ?* 设置队列最大数据条数? ?* @param resource $hr? ?* @param string ? $queue? ?* @param int ? ? ?$maxqueue 队列最大数据条数? ?* @return boolean? ?*/? $maxqueueRes = httpsqs_maxqueue($hr, "testQueue", 10000);
/**? ?* 修改定时刷新内存缓冲区内容到磁盘的间隔时间? ?* @param resource $hr? ?* @param string ? $queue? ?* @param int ? ? ?$synctime 间隔时间? ?* @return boolean? ?*/? $synctimeRes = httpsqs_synctime($hr, "testQueue", 10);
对象调用
// 参数与httpsqs_connect对应? $hr = new HttpSQS($host, $port);? ? // 参数与httpsqs_get对应? $hr->get($queuename, $return_array, $charset);? ? // 参数与httpsqs_put对应? $hr->put($queuename, $data, $charset);? ? // 参数与httpsqs_status对应? $hr->status($queuename, $return_json);? ? // 参数与httpsqs_view对应? $hr->view($queuename, $pos);? ? // 参数与httpsqs_reset对应? $hr->reset($queuename);? ? // 参数与httpsqs_maxqueue对应? $hr->maxqueue($queuename);? ? // 参数与httpsqs_synctime对应? $hr->synctime($queuename);
示例
// 取数据Daemon? $hr = httpsqs_connect($host, $port);? while (1) {? ? ?
$data = httpsqs_get($hr, $queuename, $charset);? ? ?
if ($data === false) {? ? ? ? ?sleep(1);? ? ? } else {? ? ? ? // do something...? ? ? }? }? ?
?// 或者? $hr = new HttpSQS($host, $port);? while (1) {? ? ? $data = $hr->get($queuename, $charset);? ? ?
?if ($data === false) {? ? ? ? ? sleep(1);? ? ? } else {? ? ? ? // do something...? ? ? }? }? ?
?// 写数据? $hr = httpsqs_connect($hort, $port);? httpsqs_put($hr, $queuename, $data, $charset);? ?
?// 或者? $hr = new HttpSQS($hort, $port);? $hr->put($queuename, $data, $charset);
详细解决方案
php-httpsqs-client 的施用
热度:485 发布时间:2012-10-26 10:30:59.0
相关解决方案
- 小弟我想做一个多功能web service client
- com.caucho.hessian.client.HessianConnectionException: 500解决方法
- MySQL 5.5 Command Line Client 窗口1输密码就退出
- org.apache.http.client.HttpClient与org.apache.commons.httpclient.HttpClient的差别
- org.apache.axis.client.Service的有关问题
- svn版本有关问题svn:this client is too old to work with working copy.
- ORA-12518, TNS:listener could not hand off client connection
- SAP Crystal Server Client Tools开发过水晶报表过程中的参数有关问题
- Microsfot SQL Native Client Description:用户'sa'登录失败。SQL State:28000,该如何处理
- gsoap (client)调用wcf服务疏失
- VS10连接Oracle的有关问题:"Oracle.DataAccess.Client.OracleConnection"的类型初始值设定项引发错误
- System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client
- 求AJAX及java(client script)与asp.net交互,资源,网站,论坛,视频,特别是AJAX要从最基础到最深入系统的学习,代码,实例,理论。解决方案
- Smart Client Software Factory(SCSF)解决办法
- System.Data.OracleClient requires Oracle client software version 8.1.7 or greater
- 求sybase client fro vista解决方案
- 在win2k SVR上安装sybase12 Client 出错了,该如何解决
- 项目出现上列异常com.sun.jersey.api.client.ClientHandlerException
- Oracle 10g client for Solaris,该怎么解决
- 苦痛!该修改的都改了,为啥共享光驱网络安装SOLARIS,执行add_install_client却报Error: unknown client?
- 【2010.11.08】SVN版本有关问题:This client is too old to work with working copy
- svn&httpsqs&cdn.(仅做记录)
- SVN:This client is too old to work with working copy解决方法
- SVN有关问题:This client is too old to work with working copy
- sip client 不能登录到asterisk sever解决办法
- sip client 不能登录到asterisk sever,该怎么处理
- Android下试用Linphone(Free SIP VOIP Client)
- sip client 不能登录到asterisk sever,该怎么解决
- 用gsoap可以实现让web server主动向web client 发送数据吗?解决方法
- c# asp.net memcached client 调用示范