Skip to content

Commit

Permalink
fix: proxy base cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
KyeeHuang committed Sep 28, 2024
1 parent af394d1 commit 0e2bbba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
1 change: 1 addition & 0 deletions src/proxy/proxy_base_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ProxyBaseCmd : public std::enable_shared_from_this<ProxyBaseCmd> {
OpType GetOpType() const { return op_type_; }
KeyType GetKeyType() const { return key_type_; }
TaskType GetTaskType() const { return task_type_; }
virtual std::shared_ptr<PClient> Client() = 0;
virtual std::string GetKey() = 0;

protected:
Expand Down
5 changes: 1 addition & 4 deletions src/proxy/proxy_cmd_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ std::string SetProxyCmd::GetCommand() {

bool SetProxyCmd::DoInitial(PClient* client) {
// client
client_ = client;
client_.reset(client);
}

//
Expand All @@ -35,9 +35,6 @@ void SetProxyCmd::CallBack() {
// after DoCmd ?

client_->SetRes(CmdRes::kOK);

g_pikiwidb->PushWriteTask(client_);

}

} // namespace pikiwidb
Expand Down
4 changes: 2 additions & 2 deletions src/proxy/proxy_cmd_kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SetProxyCmd : public ProxyBaseCmd {
public:
enum SetCondition { kNONE, kNX, kXX, kEXORPX };
SetProxyCmd(std::string key, std::string value) : key_(key), value_(value) {};
PClient* Client() { return client_; }
std::shared_ptr<PClient> Client() { return client_; }

protected:
void Execute() override;
Expand All @@ -21,7 +21,7 @@ class SetProxyCmd : public ProxyBaseCmd {
std::string key_;
std::string value_;
int64_t sec_ = 0;
PClient* client_; // TODO: need to discuss
std::shared_ptr<PClient> client_; // TODO: need to discuss
Router* router_;

SetProxyCmd::SetCondition condition_{kNONE};
Expand Down
63 changes: 30 additions & 33 deletions tests/assets/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ port 9221
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#
# bind 127.0.0.1
ip 127.0.0.1


# Close the connection after a client is idle for N seconds (0 to disable)
Expand All @@ -35,7 +35,7 @@ logfile stdout
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 3
databases 16

################################ SNAPSHOTTING #################################
#
Expand Down Expand Up @@ -261,7 +261,6 @@ maxmemory-policy noeviction
#
maxmemory-samples 5


################################ THREADED I/O #################################
# So for instance if you have a four cores boxes, try to use 2 or 3 I/O
# threads, if you have a 8 cores, try to use 6 threads. In order to
Expand Down Expand Up @@ -315,37 +314,35 @@ slowlog-log-slower-than 10000
# You can reclaim memory used by the slow log with SLOWLOG RESET.
slowlog-max-len 128

############################### ADVANCED CONFIG ###############################

# Redis calls an internal function to perform many background tasks, like
# closing connections of clients in timeot, purging expired keys that are
# never requested, and so forth.
#
# Not all tasks are perforemd with the same frequency, but Redis checks for
# tasks to perform accordingly to the specified "hz" value.
#
# By default "hz" is set to 10. Raising the value will use more CPU when
# Redis is idle, but at the same time will make Redis more responsive when
# there are many keys expiring at the same time, and timeouts may be
# handled with more precision.
#
# The range is between 1 and 500, however a value over 100 is usually not
# a good idea. Most users should use the default of 10 and raise this up to
# 100 only in environments where very low latency is required.
hz 10
############################### BACKENDS CONFIG ###############################
# PikiwiDB is a in memory database, though it has aof and rdb for dump data to disk, it
# is very limited. Try use leveldb for real storage, pikiwidb as cache. The cache algorithm
# is like linux page cache, please google or read your favorite linux book
# 0 is default, no backend
# 1 is RocksDB, currently only support RocksDB
backend 1
backendpath dump
# the frequency of dump to backend per second
backendhz 10
# the rocksdb number per db
db-instance-num 5
# PikiwiDB uses RocksDB as the underlying storage engine, and the data belonging
# to the same DB is distributed among several RocksDB instances.

# RocksDB instances number per DB
db-instance-num 3
# default is 86400 * 7
small-compaction-threshold 604800
# default is 86400 * 3
small-compaction-duration-threshold 259200

############################### ROCKSDB CONFIG ###############################
rocksdb-max-subcompactions 2
rocksdb-max-background-jobs 4
rocksdb-max-write-buffer-number 2
rocksdb-min-write-buffer-number-to-merge 2
# default is 64M
rocksdb-write-buffer-size 67108864
rocksdb-level0-file-num-compaction-trigger 4
rocksdb-number-levels 7
rocksdb-enable-pipelined-write no
rocksdb-level0-slowdown-writes-trigger 20
rocksdb-level0-stop-writes-trigger 36
# default 86400 * 7
rocksdb-ttl-second 604800
# default 86400 * 3
rocksdb-periodic-second 259200
rocksdb-periodic-second 259200;

############################### RAFT ###############################
use-raft no
# Braft relies on brpc to communicate via the default port number plus the port offset
raft-port-offset 10

0 comments on commit 0e2bbba

Please sign in to comment.