PHP Classes

File: example/mqwithworker.php

Recommend this page to a friend!
  Classes of Jorge Castro  >  UsagiMQ  >  example/mqwithworker.php  >  Download  
File: example/mqwithworker.php
Role: Example script
Content type: text/plain
Description: Example script
Class: UsagiMQ
Manage message queues stored using Redis
Author: By
Last change:
Date: 2 years ago
Size: 1,410 bytes


Class file image Download
include "../UsagiMQ.php";

$usa=new UsagiMQ("",6379,1);
if (
$usa->connected) {
    if (
$usa->key) {
// method 1: calling a random worker.
        // its an example, if the operation is insert, then we call an random worker. In this case, its a local worker but it could be located in a different server
if ($usa->op=='insert') {
// method 2: load balance
if ($usa->op=='insert') {
            if (
$ic>=3) {
} else {
"not connected";

 * This operation returns nothing and takes 1ms.
 * @param string $url relative path.
function curlAsync($url) {
$actuallink = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$cleanLink=substr($actuallink ,0,strrpos($actuallink,'/')).'/'.$url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $cleanLink);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1); // for php >5.2.3
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);


For more information send a message to info at phpclasses dot org.