-
Notifications
You must be signed in to change notification settings - Fork 33
/
README
executable file
·112 lines (79 loc) · 2.97 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
===============================================
MemcacheQ - Simple Queue Service over Memcache
===============================================
Features
=========
* damn simple
* very fast
* multiple queue
* concurrent well
* memcache protocol compatible
Getting Started
===============
Download
---------
See: <http://code.google.com/p/memcacheq/downloads/list>
Installation
-------------
See: <http://memcachedb.org/memcacheq/INSTALL.html>
Please take a look at 'ChangLog' file in the distribution, see what's new.
Commands
---------
Only two commands are used to operate the queue:
**Append a message to the tail of queue**::
set <queue name> <flags> 0 <message_len>\r\n
<put your message body here>\r\n
STORED\r\n
**Note:** MQ will create a new queue automatically if your queue is not existed. The original 'expire time' field is ignored by server.
**Consume a message from the head of queue**::
get <queue name>\r\n
VALUE <queue name> <flags> <message_len>\r\n
<your message body will come here>\r\n
END\r\n
Examples
---------
Assuming you are using PHP memcache<http://www.php.net/memcache>::
<?php
/* connect to memcached server */
$memcache_obj = memcache_connect('memcacheq_host', 21201);
/* append a message to queue */
memcache_set($memcache_obj, 'demoqueue1', 'message body here', 0, 0);
/* consume a message from 'demoqueue1' */
memcache_get($memcache_obj, 'demoqueue1');
memcache_close($memcache_obj);
?>
Limitation
===========
The message body is stored in Berkeley DB with fixed length. Any message that is shorter than the declared length will automatically be padded with space character (0x20 in the ASCII character set).
In Berkeley DB, as the official document refers,
"For the Queue access method, the record length must be enough smaller than the database's page size that at least one record plus the database page's metadata information can fit on each database page."
"The minimum page size is 512 bytes, the maximum page size is 64K bytes, and the page size must be a power-of-two."
So we have a limit on the message body size with a max of a bit less than *64K*.
Other tips
===========
use 'stats queue' to see your current queues::
$ telnet 127.0.0.1 22201
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
stats queue
STAT test1 12231/12
STAT test2 23/23
STAT test3 1212/12
STAT test4 1/1
END
delete a queue::
$ telnet 127.0.0.1 22201
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
delete test1
DELETED
Feedback
=========
MemcacheDB mailing list now hosts on Google Group: http://groups.google.com/group/memcachedb
* To subscribe to maillist, send email to [email protected]
* To post to maillist, send email to [email protected]
* To unsubscribe from maillist, send email to [email protected]
Please report your bugs and issues to the Maillist.
Last updated by Steve Chu<http://stvchu.org>: 12/09/2009