Esempio n. 1
0
//-----------------------------------------------------------------------------
CRedisClient::CRedisClient( std::string hostname, int port )
{
  mHostName = hostname;
  mPort = port;
  mRedisCon = credis_connect(hostname.c_str(), port, REDIS_TIMEOUT);
  if (mRedisCon == NULL)
    PRT_ERR2("Failed to connect to Redis server at %s:%d", mHostName.c_str(),
              mPort);
}
Esempio n. 2
0
//---------------------------------------------------------------------------
float CGridMap::getCellValue ( CPoint2d pos ) const
{
  int x, y;

  x = mCenterCellX + ( int ) round ( pos.mX / mCellSize );
  y = mCenterCellY + ( int ) round ( pos.mY / mCellSize );

  if ( ( x > 0 ) && ( x < mNumCellsX ) && ( y > 0 ) && ( y < mNumCellsY ) )
    return mMapData[x][y];

  PRT_ERR2 ( "Location outside of map %f %f \n", pos.mX, pos.mY );

  return 0;
}
Esempio n. 3
0
//-----------------------------------------------------------------------------
int CRedisClient::printInfo()
{
  REDIS_INFO info;

  if (not mRedisCon)
    return 0; // failure

  if (credis_info(mRedisCon, &info) != 0) {
    PRT_ERR2("No answer from Redis server %s:%d", mHostName.c_str(), mPort);
    return 0; // failure
  }

  printf("REDIS Information: \n"                   \
         "  version: %s\n"                         \
         "  uptime in seconds: %d\n"               \
         "  uptime in days: %d\n"                  \
         "  connected clients: %d\n"               \
         "  connected slaves: %d\n"                \
         "  used memory: %u\n"                     \
         "  changes since last save: %lld\n"       \
         "  bgsave in progress: %d\n"              \
         "  last save time: %d\n"                  \
         "  total connections received: %lld\n"    \
         "  total commands processed: %lld\n"      \
         "  role: %d\n",
         info.redis_version,
         info.uptime_in_seconds,
         info.uptime_in_days,
         info.connected_clients,
         info.connected_slaves,
         info.used_memory,
         info.changes_since_last_save,
         info.bgsave_in_progress,
         info.last_save_time,
         info.total_connections_received,
         info.total_commands_processed,
         info.role);
  return 1; // success
}