-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset.php
54 lines (41 loc) · 761 Bytes
/
set.php
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
<?php
include 'core.php';
validateRequest();
$pair = getInput();
$db = openDatabase();
$query = sprintf("
insert into `keyvaluestore` (
`key`,
`value`
) values (
'%s',
'%s'
)
on duplicate key update
`key` = values(`key`),
`value` = values(`value`);
delete `keyvaluestore`
from
`keyvaluestore`
left join
(
select `key`
from `keyvaluestore`
order by `modified` desc
limit 500
) as `keep`
on `keyvaluestore`.`key`= `keep`.`key`
where
`keep`.`key` is null;
OPTIMIZE TABLE `keyvaluestore`;
",
$db->real_escape_string($pair->key),
$db->real_escape_string($pair->value));
$reader = $db->multi_query($query);
if($reader === false) {
showError($db->error);
exit;
}
showPair($pair->key, $pair->value);
$db->close();
?>