strukt/queue

Memcached Queue

dev-master 2024-01-25 02:20 UTC

This package is not auto-updated.

Last update: 2024-05-02 03:33:55 UTC


README

Simple implementation of a Message Queue that uses Memcached https://memcached.org/ as backend

Needs PHP Memcached extensions installed to work properly

@author Maurizio Giunti https://www.mauriziogiunti.it / https://codeguru.it
@license MIT

Usage

Wait

//wait.php
$data = ["username"=>"pitsolu", "password"=>"p@55w0rd"];
wait("queue_test", $data, function($reply){

	print_r($reply);
});

Reply

//reply.php
reply("queue_test", function($data){

	$data["processed"] = true;

	return $data;
});

Other Usages

Pop

$data = array(
	"username"=>"pitsolu", 
	"password"=>"p@55w0rd"
);

$uid = push("queue_test", $data);

Push

list($oid, $udata) = pop("queue_test");

print_r(array(

	"uid"=>$uid,
	"oid"=>$oid,
	"data"=>$data,
	"udata"=>$udata
));