<commit_before>#include "libmemcached/memcached.h"
#include <string.h>
#include <stdio.h>

#include <string>

class Memcached
{
  memcached_st memc;
  memcached_result_st result;

public:

  Memcached() 
    : 
      memc(),
      result()
  {
    memcached_create(&memc);
  }

  Memcached(memcached_st *clone) 
    : 
      memc(),
      result()
  {
    memcached_clone(&memc, clone);
  }

  ~Memcached()
  {
    memcached_free(&memc);
  }

  std::string fetch(const std::string& key, size_t *key_length, size_t *value_length)
  {
    uint32_t flags;
    memcached_return rc;
    std::string ret_val;

    char *value= memcached_fetch(&memc, const_cast<char *>(key.c_str()), key_length,
                                 value_length, &flags, &rc);
    if (value)
    {
      ret_val.assign(value);
    }
    return ret_val;
  }

  std::string get(const std::string& key, size_t *value_length)
  {
    uint32_t flags;
    memcached_return rc;
    std::string ret_val;

    char *value= memcached_get(&memc, key.c_str(), key.length(),
                               value_length, &flags, &rc);
    if (value)
    {
      ret_val.assign(value);
    }
    return ret_val;
  }

  std::string get_by_key(const std::string& master_key, 
                   const std::string& key, 
                   size_t *value_length)
  {
    uint32_t flags;
    memcached_return rc;
    std::string ret_val;

    char *value= memcached_get_by_key(&memc, master_key.c_str(), master_key.length(), 
                                      key.c_str(), key.length(),
                                      value_length, &flags, &rc);
    if (value)
    {
      ret_val.assign(value);
    }
    return ret_val;
  }

  memcached_return mget(char **keys, size_t *key_length, 
                        unsigned int number_of_keys)
  {

    return memcached_mget(&memc, keys, key_length, number_of_keys);
  }

  bool set(const std::string& key, const char *value, size_t value_length)
  {
    memcached_return rc= memcached_set(&memc, key.c_str(), key.length(),
                                       value, value_length,
                                       time_t(0), uint32_t(0));
    return (rc == MEMCACHED_SUCCESS);
  }

  bool set_by_key(const std::string& master_key, 
                  const std::string& key, 
                  const char *value, size_t value_length)
  {
    memcached_return rc= memcached_set_by_key(&memc, master_key.c_str(), 
                                              master_key.length(),
                                              key.c_str(), key.length(),
                                              value, value_length,
                                              time_t(0),
                                              uint32_t(0));
    return (rc == MEMCACHED_SUCCESS);
  }

  bool increment(const std::string& key, unsigned int offset, uint64_t *value)
  {
    memcached_return rc= memcached_increment(&memc, key.c_str(), key.length(),
                                             offset, value);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool decrement(const char *key, unsigned int offset, uint64_t *value)
  {
    memcached_return rc= memcached_decrement(&memc, key, strlen(key),
                                             offset, value);
    return (rc == MEMCACHED_SUCCESS);
  }


  bool add(const char *key, const char *value, size_t value_length)
  {
    memcached_return rc= memcached_add(&memc, key, strlen(key), value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool add_by_key(const char *master_key, const char *key, 
                  const char *value, size_t value_length)
  {
    memcached_return rc= memcached_add_by_key(&memc, master_key, strlen(master_key),
                                              key, strlen(key),
                                              value, value_length,
                                              0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool replace(const char *key, const char *value, 
               size_t value_length)
  {
    memcached_return rc= memcached_replace(&memc, key, strlen(key),
                                           value, value_length,
                                           0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool replace_by_key(const char *master_key, const char *key, 
                      const char *value, size_t value_length)
  {
    memcached_return rc= memcached_replace_by_key(&memc, master_key, strlen(master_key),
                                                  key, strlen(key),
                                                  value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool prepend(const char *key, const char *value, 
               size_t value_length)
  {
    memcached_return rc= memcached_prepend(&memc, key, strlen(key),
                                           value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool prepend_by_key(const char *master_key, const char *key, 
                      const char *value, size_t value_length)
  {
    memcached_return rc= memcached_prepend_by_key(&memc, master_key, strlen(master_key),
                                                  key, strlen(key),
                                                  value, value_length,
                                                  0,
                                                  0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool append(const char *key, const char *value, 
              size_t value_length)
  {
    memcached_return rc= memcached_append(&memc, key, strlen(key),
                                          value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool append_by_key(const char *master_key, const char *key, 
                     const char *value, size_t value_length)
  {
    memcached_return rc= memcached_append_by_key(&memc,
                                                 master_key, strlen(master_key),
                                                 key, strlen(key),
                                                 value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool cas(const char *key, const char *value, 
           size_t value_length, uint64_t cas_arg)
  {
    memcached_return rc= memcached_cas(&memc, key, strlen(key),
                                       value, value_length, 0, 0, cas_arg);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool cas_by_key(const char *master_key, const char *key, 
                  const char *value, size_t value_length, 
                  uint64_t cas_arg)
  {
    memcached_return rc= memcached_cas_by_key(&memc,
                                              master_key, strlen(master_key),
                                              key, strlen(key),
                                              value, value_length,
                                              0, 0, cas_arg);
    return (rc == MEMCACHED_SUCCESS);
  }

  // using 'remove' vs. 'delete' since 'delete' is a keyword 
  bool remove(const std::string& key)
  {
    memcached_return rc= memcached_delete(&memc, key.c_str(), key.length(), 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool delete_by_key(const char *master_key, const char *key)
  {
    memcached_return rc= memcached_delete_by_key(&memc, master_key, strlen(master_key),
                                                 key, strlen(key), 0);
    return (rc == MEMCACHED_SUCCESS);
  }
};
<commit_msg>Removing un-needed include declaration from C++ interface.<commit_after>#include "libmemcached/memcached.h"
#include <string.h>

#include <string>

class Memcached
{
  memcached_st memc;
  memcached_result_st result;

public:

  Memcached() 
    : 
      memc(),
      result()
  {
    memcached_create(&memc);
  }

  Memcached(memcached_st *clone) 
    : 
      memc(),
      result()
  {
    memcached_clone(&memc, clone);
  }

  ~Memcached()
  {
    memcached_free(&memc);
  }

  std::string fetch(const std::string& key, size_t *key_length, size_t *value_length)
  {
    uint32_t flags;
    memcached_return rc;
    std::string ret_val;

    char *value= memcached_fetch(&memc, const_cast<char *>(key.c_str()), key_length,
                                 value_length, &flags, &rc);
    if (value)
    {
      ret_val.assign(value);
    }
    return ret_val;
  }

  std::string get(const std::string& key, size_t *value_length) 
  {
    uint32_t flags;
    memcached_return rc;
    std::string ret_val;

    char *value= memcached_get(&memc, key.c_str(), key.length(),
                               value_length, &flags, &rc);
    if (value)
    {
      ret_val.assign(value);
    }
    return ret_val;
  }

  std::string get_by_key(const std::string& master_key, 
                         const std::string& key, 
                         size_t *value_length)
  {
    uint32_t flags;
    memcached_return rc;
    std::string ret_val;

    char *value= memcached_get_by_key(&memc, master_key.c_str(), master_key.length(), 
                                      key.c_str(), key.length(),
                                      value_length, &flags, &rc);
    if (value)
    {
      ret_val.assign(value);
    }
    return ret_val;
  }

  memcached_return mget(char **keys, size_t *key_length, 
                        unsigned int number_of_keys)
  {

    return memcached_mget(&memc, keys, key_length, number_of_keys);
  }

  bool set(const std::string& key, const char *value, size_t value_length)
  {
    memcached_return rc= memcached_set(&memc, key.c_str(), key.length(),
                                       value, value_length,
                                       time_t(0), uint32_t(0));
    return (rc == MEMCACHED_SUCCESS);
  }

  bool set_by_key(const std::string& master_key, 
                  const std::string& key, 
                  const char *value, size_t value_length)
  {
    memcached_return rc= memcached_set_by_key(&memc, master_key.c_str(), 
                                              master_key.length(),
                                              key.c_str(), key.length(),
                                              value, value_length,
                                              time_t(0),
                                              uint32_t(0));
    return (rc == MEMCACHED_SUCCESS);
  }

  bool increment(const std::string& key, unsigned int offset, uint64_t *value)
  {
    memcached_return rc= memcached_increment(&memc, key.c_str(), key.length(),
                                             offset, value);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool decrement(const char *key, unsigned int offset, uint64_t *value)
  {
    memcached_return rc= memcached_decrement(&memc, key, strlen(key),
                                             offset, value);
    return (rc == MEMCACHED_SUCCESS);
  }


  bool add(const char *key, const char *value, size_t value_length)
  {
    memcached_return rc= memcached_add(&memc, key, strlen(key), value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool add_by_key(const char *master_key, const char *key, 
                  const char *value, size_t value_length)
  {
    memcached_return rc= memcached_add_by_key(&memc, master_key, strlen(master_key),
                                              key, strlen(key),
                                              value, value_length,
                                              0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool replace(const char *key, const char *value, 
               size_t value_length)
  {
    memcached_return rc= memcached_replace(&memc, key, strlen(key),
                                           value, value_length,
                                           0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool replace_by_key(const char *master_key, const char *key, 
                      const char *value, size_t value_length)
  {
    memcached_return rc= memcached_replace_by_key(&memc, master_key, strlen(master_key),
                                                  key, strlen(key),
                                                  value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool prepend(const char *key, const char *value, 
               size_t value_length)
  {
    memcached_return rc= memcached_prepend(&memc, key, strlen(key),
                                           value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool prepend_by_key(const char *master_key, const char *key, 
                      const char *value, size_t value_length)
  {
    memcached_return rc= memcached_prepend_by_key(&memc, master_key, strlen(master_key),
                                                  key, strlen(key),
                                                  value, value_length,
                                                  0,
                                                  0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool append(const char *key, const char *value, 
              size_t value_length)
  {
    memcached_return rc= memcached_append(&memc, key, strlen(key),
                                          value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool append_by_key(const char *master_key, const char *key, 
                     const char *value, size_t value_length)
  {
    memcached_return rc= memcached_append_by_key(&memc,
                                                 master_key, strlen(master_key),
                                                 key, strlen(key),
                                                 value, value_length, 0, 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool cas(const char *key, const char *value, 
           size_t value_length, uint64_t cas_arg)
  {
    memcached_return rc= memcached_cas(&memc, key, strlen(key),
                                       value, value_length, 0, 0, cas_arg);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool cas_by_key(const char *master_key, const char *key, 
                  const char *value, size_t value_length, 
                  uint64_t cas_arg)
  {
    memcached_return rc= memcached_cas_by_key(&memc,
                                              master_key, strlen(master_key),
                                              key, strlen(key),
                                              value, value_length,
                                              0, 0, cas_arg);
    return (rc == MEMCACHED_SUCCESS);
  }

  // using 'remove' vs. 'delete' since 'delete' is a keyword 
  bool remove(const std::string& key)
  {
    memcached_return rc= memcached_delete(&memc, key.c_str(), key.length(), 0);
    return (rc == MEMCACHED_SUCCESS);
  }

  bool delete_by_key(const char *master_key, const char *key)
  {
    memcached_return rc= memcached_delete_by_key(&memc, master_key, strlen(master_key),
                                                 key, strlen(key), 0);
    return (rc == MEMCACHED_SUCCESS);
  }
};

{'fraction_non_alphanumeric': 0.09585853885528153, 'fraction_numerical': 0.005849896962042146, 'mean_word_length': 1.572943389772533, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 124, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2611824', 'n_tokens_mistral': 4384, 'n_tokens_neox': 4186, 'n_words': 982}