This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcc
executable file
·76 lines (58 loc) · 2.59 KB
/
mcc
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
#!/usr/bin/env php
<?php
define('CLI_NAME', 'Memcached Cli');
define('CLI_VERSION', '1.0.0-beta2');
$autoloaders = [
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../vendor/autoload.php'
];
foreach ($autoloaders as $file) {
if (file_exists($file)) {
require $file;
break;
}
}
use fortabbit\MemcachedCli\Application;
use fortabbit\MemcachedCli\Commands;
use fortabbit\MemcachedCli\ConsoleOutput as FortrabbitConsoleOutput;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
$app = new Application(CLI_NAME, CLI_VERSION);
$defaultDescriptions = [
'--server' => 'Example: 123-foo.host.com:11222 or 127.0.0.1 (port defaults to 11211)',
];
// mc delete
$app->command('delete key [-s|--server=]*', new Commands\Delete())->descriptions("Delete item from cache", $defaultDescriptions + [
'key' => 'Cache key']);
// mc flush
$app->command('flush [-s|--server=]*', new Commands\Flush())->descriptions("Flush entire cache", $defaultDescriptions);
// mc get
$app->command('get key [-s|--server=]*', new Commands\Get())->descriptions("Get item from cache", $defaultDescriptions + [
'key' => 'Cache key']);
// mc faker
$app->command('faker prefix [-s|--server=]* [--size=] [--count=] [--ttl=]', new Commands\Faker())->descriptions("Create a set fake data", $defaultDescriptions + [
'prefix' => 'Cache key prefix',
'--size' => 'Number of bytes of the cache item',
'--count'=> 'Number of cache items',
'--ttl' => 'Cache ttl in seconds'
]);
// mc search
$app->command('search pattern [-s|--server=]*', new Commands\Search())->descriptions("Search with a pattern that matchs the key",
$defaultDescriptions + [
'pattern' => 'Wildcard example: "prefix_key_*" or "*key-middle-part*_suffix"']);
// mc set
$app->command('set key value [-s|--server=]* [--type=] [--ttl=]', new Commands\Set())->descriptions("Store item in cache",
$defaultDescriptions + [
'key' => 'Cache key',
'value' => 'Value you want do store',
'--type' => 'Typecast the input string value to bool, int or float.',
'--ttl' => 'Cache ttl in seconds']);
// mc stats
$app->command('stats [-s|--server=]* [--full]', new Commands\Stats())->descriptions("Show stats and configuration", $defaultDescriptions);
$output = new ConsoleOutput();
$output->getFormatter()->setStyle('comment', new \Symfony\Component\Console\Formatter\OutputFormatterStyle(null, null, ['bold']));
$app->run(null, new FortrabbitConsoleOutput(
new ArgvInput(),
$output
));