PHP code example of youthage / httpsqs

1. Go to this page and download the library: Download youthage/httpsqs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

youthage / httpsqs example snippets



use Httpsqs\HttpSQS;

$httpsqs = new HttpSQS($host, $port, $auth, $charset);


//get: 如果队列为空 返回 "HTTPSQS_GET_END"
$result = $httpsqs->get('test'); // example1

//gets: 队列为空返回 array('pos'=>null, 'data'=> "HTTPSQS_GET_END" );

$result = $httpsqs->gets('test'); // array('pos'=>1, 'data'=>'example1');

$result = $httpsqs->status('test');

//字符串形式
 HTTP Simple Queue Service v1.7 
------------------------------ 
Queue Name: newiep 
Maximum number of queues: 1000000 
Put position of queue (1st lap): 13 
Get position of queue (1st lap): 12 
Number of unread queue: 1 

//json 格式
$result = $httpsqs->status('test', 'status_json');

{"name":"test","maxqueue":1000000,"putpos":45,"putlap":1,"getpos":6,"getlap":1,"unread":39}

$result = $httpsqs->view('test', 1);  //  example1

//将队列重置,从开始位置重新写入

$result = $httpsqs->reset('test'); //true

//修改的数值需满足条件:($num >=10 && $num <= 1000000000)

$result = $httpsqs->maxqueue('test', 1000); //true

$result = $httpsqs->maxqueue('test', 1); //false

// 默认间隔时间:5秒

$result = $foo->synctime(10); //true