FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-memcached/tests/server.php at master · php-memcached-dev/php-memcached · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
php-memcached-dev
/
php-memcached
Public
Notifications
You must be signed in to change notification settings
Fork
326
Star
1k
Code
Issues
46
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
php-memcached
/
tests
/
server.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
111 lines (93 loc) · 4.68 KB
Breadcrumbs
php-memcached
/
tests
/
server.php
Copy path
File metadata and controls
111 lines (93 loc) · 4.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
$
server
=
new
MemcachedServer
();
$
server
->
on
(Memcached::
ON_CONNECT
,
function
(
$
remote_addr
) {
echo
"
Incoming connection from
{
$
remote_addr
}"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_ADD
,
function
(
$
client_id
,
$
key
,
$
value
,
$
flags
,
$
expiration
, &
$
cas
) {
echo
"
client_id=[
$
client_id
]: Add key=[
$
key
], value=[
$
value
], flags=[
$
flags
], expiration=[
$
expiration
]
"
.
PHP_EOL
;
$
cas
=
15
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_APPEND
,
function
(
$
client_id
,
$
key
,
$
value
,
$
cas
, &
$
result_cas
) {
echo
"
client_id=[
$
client_id
]: Append key=[
$
key
], value=[
$
value
], cas=[
$
cas
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_PREPEND
,
function
(
$
client_id
,
$
key
,
$
value
,
$
cas
, &
$
result_cas
) {
echo
"
client_id=[
$
client_id
]: Prepend key=[
$
key
], value=[
$
value
], cas=[
$
cas
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_INCREMENT
,
function
(
$
client_id
,
$
key
,
$
delta
,
$
initial
,
$
expiration
, &
$
result
, &
$
result_cas
) {
echo
"
client_id=[
$
client_id
]: Incrementing key=[
$
key
], delta=[
$
delta
], initial=[
$
initial
], expiration=[
$
expiration
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_DECREMENT
,
function
(
$
client_id
,
$
key
,
$
delta
,
$
initial
,
$
expiration
, &
$
result
, &
$
result_cas
) {
echo
"
client_id=[
$
client_id
]: Decrementing key=[
$
key
], delta=[
$
delta
], initial=[
$
initial
], expiration=[
$
expiration
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_DELETE
,
function
(
$
client_id
,
$
key
,
$
cas
) {
echo
"
client_id=[
$
client_id
]: Delete key=[
$
key
], cas=[
$
cas
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_FLUSH
,
function
(
$
client_id
,
$
when
) {
echo
"
client_id=[
$
client_id
]: Flush when=[
$
when
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_GET
,
function
(
$
client_id
,
$
key
, &
$
value
, &
$
flags
, &
$
cas
) {
echo
"
client_id=[
$
client_id
]: Get key=[
$
key
]
"
.
PHP_EOL
;
$
value
=
"
Hello to you client!
"
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_NOOP
,
function
(
$
client_id
) {
echo
"
client_id=[
$
client_id
]: Noop
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_REPLACE
,
function
(
$
client_id
,
$
key
,
$
value
,
$
flags
,
$
expiration
,
$
cas
, &
$
result_cas
) {
echo
"
client_id=[
$
client_id
]: Replace key=[
$
key
], value=[
$
value
], flags=[
$
flags
], expiration=[
$
expiration
], cas=[
$
cas
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_SET
,
function
(
$
client_id
,
$
key
,
$
value
,
$
flags
,
$
expiration
,
$
cas
, &
$
result_cas
) {
echo
"
client_id=[
$
client_id
]: Set key=[
$
key
], value=[
$
value
], flags=[
$
flags
], expiration=[
$
expiration
], cas=[
$
cas
]
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_STAT
,
function
(
$
client_id
,
$
key
,
array
&
$
values
) {
echo
"
client_id=[
$
client_id
]: Stat key=[
$
key
]
"
.
PHP_EOL
;
if
(
$
key
===
"
scalar
"
) {
$
values
=
"
you want it, you get it
"
;
}
elseif
(
$
key
===
"
numeric array
"
) {
$
values
= [-
1
=>
"
one
"
,
"
two
"
,
"
three
"
];
}
elseif
(
$
key
===
"
empty
"
) {
$
values
= [];
}
else
{
$
values
[
"
key
"
] =
$
key
;
$
values
[
"
foo
"
] =
"
bar
"
;
}
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_VERSION
,
function
(
$
client_id
, &
$
value
) {
echo
"
client_id=[
$
client_id
]: Version
"
.
PHP_EOL
;
$
value
=
"
1.1.1
"
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
server
->
on
(Memcached::
ON_QUIT
,
function
(
$
client_id
) {
echo
"
client_id=[
$
client_id
]: Client quit
"
.
PHP_EOL
;
return
Memcached::
RESPONSE_SUCCESS
;
});
$
addr
= (
$
_SERVER
[
'
argv
'
][
1
] ??
"
127.0.0.1:3434
"
);
echo
"
Listening on
$
addr
"
.
PHP_EOL
;
$
server
->
run
(
$
addr
);
Back
|
FazBrowse Home
|
New Git URL