Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F35257620
krinkle-tmp.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Krinkle
Jun 21 2022, 1:14 AM
2022-06-21 01:14:39 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
krinkle-tmp.php
View Options
<?php
/*
[01:04 UTC] krinkle at mwmaint1002.eqiad.wmnet in ~
$ mwscript eval.php --wiki aawiki
> require '/home/krinkle/krinkle-tmp.php';
Done setting 6806 keys
Sleeping for 45 seconds...
Checking...
Checked 6806 keys.
Done!
*/
use
MediaWiki\MediaWikiServices
;
class
KrinkleTmp
{
const
TIME_STORED
=
60
;
const
TIME_SETTING
=
5
;
const
TIME_WAIT
=
45
;
const
MAX_KEYS
=
10000
;
public
$stored
=
[];
public
$wanCache
;
public
function
__construct
()
{
$this
->
wanCache
=
MediaWikiServices
::
getInstance
()->
getMainWANObjectCache
();
}
public
function
add
(
int
$i
):
void
{
$key
=
$this
->
wanCache
->
makeGlobalKey
(
'krinkle-tmp'
,
'num'
.
$i
);
$val
=
'some_interesting_data_here'
.
$i
;
$this
->
stored
[]
=
[
'key'
=>
$key
,
'val'
=>
$val
,
'res'
=>
$this
->
wanCache
->
set
(
$key
,
$val
,
self
::
TIME_STORED
),
'time'
=>
microtime
(
true
),
];
}
public
function
check
(
array
$entry
):
void
{
$actual
=
$this
->
wanCache
->
get
(
$entry
[
'key'
]);
if
(
$actual
!==
$entry
[
'val'
])
{
$now
=
microtime
(
true
);
$this
->
report
(
$entry
,
$now
,
$actual
);
}
}
public
function
report
(
array
$entry
,
$now
,
$actual
):
void
{
print
sprintf
(
"Key %s was %s after %s seconds (res: %s)
\n
"
,
$entry
[
'key'
],
(
$actual
===
false
?
'missing'
:
json_encode
(
$actual
)),
round
(
$now
-
$entry
[
'time'
]),
json_encode
(
entry
[
'res'
])
);
}
public
function
execute
():
void
{
$t1
=
microtime
(
true
);
$i
=
0
;
while
(
(
microtime
(
true
)
-
$t1
)
<
self
::
TIME_SETTING
&&
$i
<
self
::
MAX_KEYS
)
{
$this
->
add
(
$i
);
$i
++;
}
print
"Done setting $i keys
\n
"
;
print
"Sleeping for "
.
self
::
TIME_WAIT
.
" seconds...
\n
"
;
$this
->
wanCache
->
clearProcessCache
();
sleep
(
self
::
TIME_WAIT
);
print
"Checking...
\n
"
;
$i
=
0
;
foreach
(
$this
->
stored
as
$entry
)
{
$this
->
check
(
$entry
);
$i
++;
}
print
"Checked $i keys.
\n
"
;
print
"Done!
\n
"
;
}
}
$tmp
=
new
KrinkleTmp
();
$tmp
->
execute
();
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9535609
Default Alt Text
krinkle-tmp.php (1 KB)
Attached To
Mode
P29911 krinkle-tmp.php
Attached
Detach File
Event Timeline
Log In to Comment