}
            }
        }
        ksort($this->list);
    }
}
$host = '127.0.0.1';
$port = '11211';
$allowedArgs = array('-h' => 'host', '-p' => 'port', '-op' => 'action', '-f' => 'file');
foreach ($allowedArgs as $key => $val) {
    $id = array_search($key, $argv);
    if ($id) {
        ${$val} = isset($argv[$id + 1]) ? $argv[$id + 1] : false;
    }
}
$obj = new memcachedTools($host, $port);
// get the filename value (if pressent) and allocate to $obj->filename
if (isset($filename) && trim($filename) != '') {
    $obj->filename = trim($filename);
}
switch ($action) {
    case 'backup':
        $obj->getAllKeys();
        $obj->writeKeysToFile();
        echo "Memcached Data has been saved to file :" . $obj->filename;
        break;
    case 'restore':
        $retval = $obj->writeKeysToMemcached();
        if (!$retval) {
            echo "Memcached Data could not be restored: " . $obj->filename . " Not Found\r\n";
        } else {