Skip to content

Commit

Permalink
Update README,modify build script,add compilation information
Browse files Browse the repository at this point in the history
  • Loading branch information
lqxhub committed Apr 1, 2024
1 parent e065fdf commit 54e50ae
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 26 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ENDIF ()
ELSEIF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")
MESSAGE(FATAL_ERROR "GCC G++ version must be greater than 10.0")
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0")
MESSAGE(FATAL_ERROR "GCC G++ version must be greater than 11.0")
ENDIF ()
ENDIF ()

# get current date and time
EXECUTE_PROCESS(COMMAND date "+%Y-%m-%d_%H:%M:%S" OUTPUT_VARIABLE BUILD_TIMESTAMP OUTPUT_STRIP_TRAILING_WHITESPACE)
ADD_DEFINITIONS(-DKPIKIWIDB_BUILD_DATE="${BUILD_TIMESTAMP}")

message(STATUS "Build timestamp: ${BUILD_TIMESTAMP}")

# get git commit id
EXECUTE_PROCESS(COMMAND git rev-parse HEAD OUTPUT_VARIABLE GIT_COMMIT_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
ADD_DEFINITIONS(-DKPIKIWIDB_GIT_COMMIT_ID="${GIT_COMMIT_ID}")
MESSAGE(STATUS "Git commit id: ${GIT_COMMIT_ID}")

############# You should enable sanitizer if you are developing pika #############
# Uncomment the following two lines to enable AddressSanitizer to detect memory leaks and other memory-related bugs.
Expand Down
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,44 @@
![](docs/images/pikiwidb-logo.png)
[中文](README_CN.md)

A C++11 implementation of Redis Server, use RocksDB for persist storage.(not including cluster yet)
A C++20 implementation of Redis Server, use RocksDB for persist storage.(not including cluster yet)

## Requirements
* C++11

* C++20
* Linux or OS X

## compile

**It is recommended to use the latest version of Ubuntu or Debian for Linux systems**

Execute compilation

If the machine's GCC version is less than 11, especially on CentOS6 or CentOS7, you need to upgrade the gcc version
first.

Execute the following commands on CentOS:

```bash
sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++
scl enable devtoolset-11 bash
```

Execute this command to start compiling Pikiwidb:

```bash
./build.sh
```

Pikiwidb is compiled by default in release mode, which does not support debugging. If debugging is needed, compile in
debug mode.

```bash
./clean.sh
./build.sh --debug
```

## Support module for write your own extensions
PikiwiDB supports module now, still in progress, much work to do.
I added three commands(ldel, skeys, hgets) for demonstration.
Expand Down
34 changes: 32 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,42 @@
![](docs/images/pikiwidb-logo.png)
[Click me switch to English](README.en.md)

C++11实现的增强版Redis服务器,使用RocksDB作为持久化存储引擎。(集群支持尚正在计划中)
C++20实现的增强版Redis服务器,使用RocksDB作为持久化存储引擎。(集群支持尚正在计划中)

## 环境需求
* C++11、CMake

* C++20、CMake
* Linux 或 MAC OS

## 编译

**建议使用最新版本的Ubuntu或Debian Linux系统**

执行编译:

如果机器的GCC版本低于11,特别是在CentOS6或CentOS7上,你需要先升级gcc版本。

在CentOS上执行以下命令:

```bash
sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++
scl enable devtoolset-11 bash
```

执行以下命令开始编译Pikiwidb:

```bash
./build.sh
```

Pikiwidb默认以release模式编译,不支持调试。如果需要调试,请以debug模式编译。

```bash
./clean.sh
./build.sh --debug
```

## 与Redis完全兼容
你可以用redis的各种工具来测试PikiwiDB,比如官方的redis-cli, redis-benchmark。

Expand Down
16 changes: 1 addition & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ C_GREEN="\033[32m"

C_END="\033[0m"

BUILD_TIME=$(git log -1 --format=%ai)
BUILD_TIME=${BUILD_TIME: 0: 10}

COMMIT_ID=$(git rev-parse HEAD)
SHORT_COMMIT_ID=${COMMIT_ID: 0: 8}

BUILD_TYPE=release
VERBOSE=0
CMAKE_FLAGS=""
Expand Down Expand Up @@ -66,19 +60,11 @@ fi

echo "cpu core ${CPU_CORE}"

if [ -z "$SHORT_COMMIT_ID" ]; then
echo "no git commit id"
SHORT_COMMIT_ID="pikiwidb"
fi

echo "BUILD_TIME:" $BUILD_TIME
echo "COMMIT_ID:" $SHORT_COMMIT_ID

echo "BUILD_TYPE:" $BUILD_TYPE
echo "CMAKE_FLAGS:" $CMAKE_FLAGS
echo "MAKE_FLAGS:" $MAKE_FLAGS

cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TIME=$BUILD_TIME -DGIT_COMMIT_ID=$SHORT_COMMIT_ID ${CMAKE_FLAGS} -S . -B ${PREFIX}
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_FLAGS} -S . -B ${PREFIX}
cmake --build ${PREFIX} -- ${MAKE_FLAGS} -j ${CPU_CORE}

if [ $? -eq 0 ]; then
Expand Down
10 changes: 6 additions & 4 deletions src/pikiwidb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ bool PikiwiDB::ParseArgs(int ac, char* av[]) {
cfg_file_ = av[i];
continue;
} else if (strncasecmp(av[i], "-v", 2) == 0 || strncasecmp(av[i], "--version", 9) == 0) {
std::cerr << "PikiwiDB Server v=" << kPIKIWIDB_VERSION << " bits=" << (sizeof(void*) == 8 ? 64 : 32) << std::endl;
std::cerr << "PikiwiDB Server version: " << KPIKIWIDB_VERSION << " bits=" << (sizeof(void*) == 8 ? 64 : 32)
<< std::endl;
std::cerr << "PikiwiDB Server Build Type: " << KPIKIWIDB_BUILD_TYPE << std::endl;
std::cerr << "PikiwiDB Server Build Date: " << KPIKIWIDB_BUILD_DATE << std::endl;
std::cerr << "PikiwiDB Server Build GIT SHA: " << KPIKIWIDB_GIT_COMMIT_ID << std::endl;

exit(0);
return true;
} else if (strncasecmp(av[i], "-h", 2) == 0 || strncasecmp(av[i], "--help", 6) == 0) {
Usage();
exit(0);
return true;
} else if (strncasecmp(av[i], "--port", 6) == 0) {
if (++i == ac) {
return false;
Expand Down Expand Up @@ -308,7 +310,7 @@ int main(int ac, char* av[]) {

// output logo to console
char logo[512] = "";
snprintf(logo, sizeof logo - 1, pikiwidbLogo, kPIKIWIDB_VERSION, static_cast<int>(sizeof(void*)) * 8,
snprintf(logo, sizeof logo - 1, pikiwidbLogo, KPIKIWIDB_VERSION, static_cast<int>(sizeof(void*)) * 8,
static_cast<int>(pikiwidb::g_config.port));
std::cout << logo;

Expand Down
8 changes: 7 additions & 1 deletion src/pikiwidb.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
#include "io_thread_pool.h"
#include "tcp_connection.h"

#define kPIKIWIDB_VERSION "4.0.0"
#define KPIKIWIDB_VERSION "4.0.0"

#ifdef BUILD_DEBUG
# define KPIKIWIDB_BUILD_TYPE "DEBUG"
#else
# define KPIKIWIDB_BUILD_TYPE "RELEASE"
#endif

class PikiwiDB final {
public:
Expand Down

0 comments on commit 54e50ae

Please sign in to comment.