Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F548069
PhabricatorCacheManagementPurgeWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorCacheManagementPurgeWorkflow.php
View Options
<?php
final
class
PhabricatorCacheManagementPurgeWorkflow
extends
PhabricatorCacheManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'purge'
)
->
setSynopsis
(
pht
(
'Drop data from readthrough caches.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'all'
,
'help'
=>
pht
(
'Purge all caches.'
),
),
array
(
'name'
=>
'caches'
,
'param'
=>
'keys'
,
'help'
=>
pht
(
'Purge a specific set of caches.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$all_purgers
=
PhabricatorCachePurger
::
getAllPurgers
();
$is_all
=
$args
->
getArg
(
'all'
);
$key_list
=
$args
->
getArg
(
'caches'
);
if
(
$is_all
&&
phutil_nonempty_string
(
$key_list
))
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify either "--all" or "--caches", not both.'
));
}
else
if
(!
$is_all
&&
!
phutil_nonempty_string
(
$key_list
))
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Select caches to purge with "--all" or "--caches". Available '
.
'caches are: %s.'
,
implode
(
', '
,
array_keys
(
$all_purgers
))));
}
if
(
$is_all
)
{
$purgers
=
$all_purgers
;
}
else
{
$key_list
=
preg_split
(
'/[
\s
,]+/'
,
$key_list
);
$purgers
=
array
();
foreach
(
$key_list
as
$key
)
{
if
(
isset
(
$all_purgers
[
$key
]))
{
$purgers
[
$key
]
=
$all_purgers
[
$key
];
}
else
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Cache purger "%s" is not recognized. Available caches '
.
'are: %s.'
,
$key
,
implode
(
', '
,
array_keys
(
$all_purgers
))));
}
}
if
(!
$purgers
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'When using "--caches", you must select at least one valid '
.
'cache to purge.'
));
}
}
$viewer
=
$this
->
getViewer
();
foreach
(
$purgers
as
$key
=>
$purger
)
{
$purger
->
setViewer
(
$viewer
);
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Purging "%s" cache...'
,
$key
));
$purger
->
purgeCache
();
}
return
0
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:43 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
109042
Default Alt Text
PhabricatorCacheManagementPurgeWorkflow.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment