Deployment
https://github.com/memcached/memcached See the file BUILD
to learn how to build.
The default configuration file /etc/memcached.conf
is used by scripts/start-memcached
when using this script to start service.
Protocol
Protocol is described in doc/protocol.txt
.
server
: 1
2
3
4
5
6
7
8
9
10
11
12$ memcached -vv -m 3 -M
<17 server listening (auto-negotiate)
<18 server listening (auto-negotiate)
<19 new auto-negotiating client connection
19: Client using the ascii protocol
<19 get foo
>19 END
<19 set foo 0 0 3
>19 STORED
<19 get foo
>19 sending key foo
>19 END
client
: 1
2
3
4
5
6
7
8
9
10$ nc -c localhost 11211
get foo
END
set foo 0 0 3
bar
STORED
get foo
VALUE foo 0 3
bar
END
Evication
server
: 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$ memcached -vv -m 3 -M
<19 new auto-negotiating client connection
19: Client using the ascii protocol
<19 set 0 0 0 10240
>19 STORED
<19 set 1 0 0 10240
>19 STORED
<19 set 2 0 0 10240
>19 STORED
<19 set 3 0 0 10240
>19 STORED
<19 set 4 0 0 10240
>19 STORED
<19 set 5 0 0 10240
>19 STORED
<19 set 6 0 0 10240
>19 STORED
......
<19 set 280 0 0 10240
>19 STORED
<19 set 281 0 0 10240
>19 STORED
<19 set 282 0 0 10240
>19 SERVER_ERROR out of memory storing object
<19 connection closed.
client
: 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# coding: utf-8
from pymemcache.client import base
def main():
client = base.Client(('localhost', 11211), default_noreply=False)
sz = 0
pos = 0
while True:
key = str(pos)
value = 'x' * 10240
try:
res = client.set(key, value)
if res:
sz += len(key) + len(value)
pos += 1
else:
break
except Exception as e:
print('exception: %s, sz: %s' % (e, sz))
break
if __name__ == "__main__":
main()1
2$ python3 main.py
exception: b'out of memory storing object', sz: 2888416
1 | package main |
1 | [2020-05-19 18:21:20] ERROR set error: memcache: unexpected response line from "set": "SERVER_ERROR out of memory storing object\r\n" |