forked from haakonnessjoen/php-beanstalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
71 lines (57 loc) · 1.54 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
1.Install libbeanstalkclient
$mkdir php-beanstalk
$cd php-beanstalk/
$wget https://github.com/bergundy/libbeanstalkclient/tarball/master --no-check-certificate
$mv master bergundy-libbeanstalkclient-b6ec294.tar.gz
$tar -xzvf bergundy-libbeanstalkclient-b6ec294.tar.gz
$mv bergundy-libbeanstalkclient-b6ec294 libbeanstalkclient
$cd libbeanstalkclient/
$mkdir m4
$sudo ./autogen.sh
$sudo vim /etc/ld.so.conf
/usr/lib
$sudo ldconfig
2.Install php-beanstalk
$wget https://github.com/nil-zhang/php-beanstalk/tarball/master --no-check-certificate
$mv master php-beanstalk.tar.gz
$tar -xzvf php-beanstalk.tar.gz
$cd php-beanstalk
$phpize
$./configure
$make
$sudo make install
$sudo vim /etc/php.d/beanstalk.ini
extension = "beanstalk.so"
$php -m
3.Using example
-----example.php----------
<?php
$bsc = new Beanstalk();
$bsc->addserver("ip1", 11300);
$bsc->addserver("ip2", 11300);
$tubes = $bsc->list_tubes();
print_r($tubes);
for($i = 0; $i < 10; $i++)
{
$key = "key".$i;
$value = "value".$i;
$bsc->use($key);
$bsc->put($key, $value);
echo "$key\t$value\n";
$bsc->watch($key);
$job = $bsc->reserve($key);
print_r($job);
if($bsc->bury($job['id'], $key))
echo "bury ok\n";
else
echo "bury failed\n";
$bsc->kick(100, $key);
if($bsc->delete($job['id'], $key))
echo "delete ok\n";
else
echo "delete failed \n";
$bsc->ignore($key);
echo "\n";
}
echo "done\n";
?>