2 +--------------------------------------------------------------------+
3 | libmemcached-awesome - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ |
13 +--------------------------------------------------------------------+
16 #include "mem_config.h"
18 #define PROGRAM_NAME "memrm"
19 #define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster."
20 #define PROGRAM_VERSION "1.1"
22 #include "common/options.hpp"
23 #include "common/checks.hpp"
25 int main(int argc
, char *argv
[]) {
26 client_options opt
{PROGRAM_NAME
, PROGRAM_VERSION
, PROGRAM_DESCRIPTION
, "key [key ...]"};
28 for (const auto &def
: opt
.defaults
) {
32 opt
.add("expire", 'e', required_argument
, "Remove based on expire time. DEPRECATED: has no effect.");
34 char **argp
= nullptr;
35 if (!opt
.parse(argc
, argv
, &argp
)) {
40 if (!check_memcached(opt
, memc
)) {
44 if (!opt
.apply(&memc
)) {
45 memcached_free(&memc
);
49 if (!check_argp(opt
, argp
, "No key(s) provided.")){
50 memcached_free(&memc
);
55 if (auto exp_str
= opt
.argof("expire")) {
56 expire
= std::stoul(exp_str
);
59 auto exit_code
= EXIT_SUCCESS
;
60 for (auto arg
= argp
; *arg
; ++arg
) {
63 if (!check_return(opt
, memc
, key
, memcached_delete(&memc
, key
, strlen(key
), expire
))) {
64 exit_code
= EXIT_FAILURE
;
69 if (!check_buffering(opt
, memc
)) {
70 exit_code
= EXIT_FAILURE
;
73 memcached_free(&memc
);