//-----------------------------------------------------------------------------
int CRedisClient::increment(const std::string key, int& newValue)
{


  if (mRedisCon) {
    if (credis_incr(mRedisCon, key.c_str(), &newValue) == 0) {
      return 1; // success
    }
  }
  return 0; // failure
}
Beispiel #2
0
const string* db_incr(closure* c, db* self, const fexp* message)
{  
  string* reply;

  string* key  = (string*)send(message, s_fexp_join, self->delimiter);  // generate a key from message
  char* keyc = (char*)send(key, s_string_tochar);
  int value  = 0;
  int rc     = credis_incr(self->handle, keyc, &value);
  if (rc != 0) {
    reply = (string*)send(VillageBus, s_villagebus_error, L"incr failed %ss", keyc);
  } else {
    reply = (string*)send(String, s_string_fromwchar, L"%d", value);
  }
  free(keyc);
  return reply;
}