-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dependency * add class rediscache and string rediscache api * add Class PCache and add dependency correctly * read cache config and add cache when processing cmd * add part kv cmd with cache * add all kv command with cache * modify list cmd with cache * delete useless code * modify hash cmd with cache * modify set cmd with cache * modify zset command with cache * modify zset part cmd with cache and fix count_ bug * comment some tcl cases * fix build ci error * tcl cases * fix rename and String2int error * fix ttl definition * clang18 format code * check clang format version
- Loading branch information
1 parent
d08c598
commit 6352471
Showing
57 changed files
with
6,680 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2024-present, Qihoo, Inc. All rights reserved. | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. An additional grant | ||
# of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
SET(REDISCACHE_SOURCES_DIR "${LIB_INSTALL_PREFIX}" CACHE PATH "rediscache source directory." FORCE) | ||
SET(REDISCACHE_INSTALL_DIR "${LIB_INSTALL_PREFIX}" CACHE PATH "rediscache install directory." FORCE) | ||
SET(REDISCACHE_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "rediscache include directory." FORCE) | ||
SET(REDISCACHE_LIBRARIES "${LIB_INSTALL_DIR}/librediscache.a" CACHE FILEPATH "rediscache library." FORCE) | ||
|
||
ExternalProject_Add( | ||
extern_rediscache | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
#URL https://github.com/pikiwidb/rediscache/archive/refs/tags/v1.0.7.tar.gz | ||
#URL_HASH MD5=02c8aadc018dd8d4d3803cc420d1d75b | ||
#temp used | ||
GIT_REPOSITORY https://github.com/hahahashen/rediscache.git | ||
GIT_TAG feat/removeUseTcMallocMacroDefinition | ||
CMAKE_ARGS | ||
-DCMAKE_BUILD_TYPE=Debug | ||
-DCMAKE_INSTALL_PREFIX=${LIB_INSTALL_PREFIX} | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-DPROJECT_BINARY_DIR=${LIB_INSTALL_PREFIX} | ||
-DCMAKE_FIND_LIBRARY_SUFFIXES=${LIB_INSTALL_PREFIX} | ||
-DSNAPPY_BUILD_TESTS=OFF | ||
-DCMAKE_INSTALL_INCLUDEDIR=${REDISCACHE_INCLUDE_DIR} | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
BUILD_COMMAND make -j${CPU_CORE} | ||
) | ||
|
||
ADD_LIBRARY(rediscache STATIC IMPORTED GLOBAL) | ||
SET_PROPERTY(TARGET rediscache PROPERTY IMPORTED_LOCATION ${REDISCACHE_LIBRARIES}) | ||
ADD_DEPENDENCIES(rediscache extern_rediscache) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) 2024-present, Qihoo, Inc. All rights reserved. | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. An additional grant | ||
# of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
FILE(GLOB PCACHE_SRC | ||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cc" | ||
) | ||
SET(LIBRARY_OUTPUT_PATH ${PLIB_INSTALL_DIR}) | ||
|
||
ADD_LIBRARY(pcache ${PCACHE_SRC}) | ||
|
||
TARGET_INCLUDE_DIRECTORIES(pcache | ||
PRIVATE ${PROJECT_SOURCE_DIR}/src | ||
PRIVATE ${rocksdb_SOURCE_DIR}/include | ||
PRIVATE ${REDISCACHE_INCLUDE_DIR} | ||
PRIVATE ${PROJECT_SOURCE_DIR}/src/pstd | ||
PRIVATE ${PROJECT_SOURCE_DIR}/src/storage/include | ||
) | ||
|
||
ADD_DEPENDENCIES(pcache rediscache storage ) | ||
|
||
TARGET_LINK_LIBRARIES(pcache pstd rediscache gflags rocksdb storage) | ||
|
||
SET_TARGET_PROPERTIES(pcache PROPERTIES LINKER_LANGUAGE CXX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2024-present, Qihoo, Inc. All rights reserved. | ||
// This source code is licensed under the BSD-style license found in the | ||
// LICENSE file in the root directory of this source tree. An additional grant | ||
// of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include "rediscache/commondef.h" | ||
|
||
namespace cache { | ||
|
||
/* Redis maxmemory strategies */ | ||
enum RedisMaxmemoryPolicy { | ||
CACHE_VOLATILE_LRU = 0, | ||
CACHE_ALLKEYS_LRU = 1, | ||
CACHE_VOLATILE_LFU = 2, | ||
CACHE_ALLKEYS_LFU = 3, | ||
CACHE_VOLATILE_RANDOM = 4, | ||
CACHE_ALLKEYS_RANDOM = 5, | ||
CACHE_VOLATILE_TTL = 6, | ||
CACHE_NO_EVICTION = 7 | ||
}; | ||
|
||
#define CACHE_DEFAULT_MAXMEMORY CONFIG_DEFAULT_MAXMEMORY // 10G | ||
#define CACHE_DEFAULT_MAXMEMORY_SAMPLES CONFIG_DEFAULT_MAXMEMORY_SAMPLES | ||
#define CACHE_DEFAULT_LFU_DECAY_TIME CONFIG_DEFAULT_LFU_DECAY_TIME | ||
|
||
/* | ||
* cache start pos | ||
*/ | ||
constexpr int CACHE_START_FROM_BEGIN = 0; | ||
constexpr int CACHE_START_FROM_END = -1; | ||
/* | ||
* cache items per key | ||
*/ | ||
#define DEFAULT_CACHE_ITEMS_PER_KEY 512 | ||
|
||
struct CacheConfig { | ||
uint64_t maxmemory; /* Can used max memory */ | ||
int32_t maxmemory_policy; /* Policy for key eviction */ | ||
int32_t maxmemory_samples; /* Precision of random sampling */ | ||
int32_t lfu_decay_time; /* LFU counter decay factor. */ | ||
int32_t zset_cache_start_direction; | ||
int32_t zset_cache_field_num_per_key; | ||
|
||
CacheConfig() | ||
: maxmemory(CACHE_DEFAULT_MAXMEMORY), | ||
maxmemory_policy(CACHE_NO_EVICTION), | ||
maxmemory_samples(CACHE_DEFAULT_MAXMEMORY_SAMPLES), | ||
lfu_decay_time(CACHE_DEFAULT_LFU_DECAY_TIME), | ||
zset_cache_start_direction(CACHE_START_FROM_BEGIN), | ||
zset_cache_field_num_per_key(DEFAULT_CACHE_ITEMS_PER_KEY) {} | ||
|
||
CacheConfig& operator=(const CacheConfig& obj) { | ||
maxmemory = obj.maxmemory; | ||
maxmemory_policy = obj.maxmemory_policy; | ||
maxmemory_samples = obj.maxmemory_samples; | ||
lfu_decay_time = obj.lfu_decay_time; | ||
zset_cache_start_direction = obj.zset_cache_start_direction; | ||
zset_cache_field_num_per_key = obj.zset_cache_field_num_per_key; | ||
return *this; | ||
} | ||
}; | ||
} // namespace cache |
Oops, something went wrong.