feat:add new command: compactrange $db $type $start_key $end_key#2163
Merged
Conversation
wanghenshui
approved these changes
Nov 24, 2023
Contributor
|
还请大佬把这个 python 测试改成 go 测试跟着这个 PR 一块提交: import redis
import sys
import time
import threading
import signal
START_FLAG = True
def random_enqueue(client: redis.Redis, quene_name: str):
while START_FLAG:
now_sec = int(time.time())
pipeline = client.pipeline(transaction=False)
for i in range(100):
score = now_sec << 16 | i
pipeline.zadd(quene_name, {str(i): score})
pipeline.execute()
print('random_enqueue exit')
def random_dequeue(client: redis.Redis, quene_name: str):
loop = 0
while START_FLAG:
start_time = time.time()
n = client.zcard(quene_name)
if n < 100:
continue
res = client.zremrangebyrank(quene_name, 0, 49)
duration = time.time() - start_time
loop += 1
if loop % 10 == 0:
print('duration: {}, res: {}'.format(duration, res))
loop = 0
print('random_dequeue exit')
def main():
if len(sys.argv) != 4:
print('Usage: python redis_queue.py <redis_host> <port> <passwd>')
sys.exit(1)
host = sys.argv[1]
port = int(sys.argv[2])
passwd = sys.argv[3]
client_enque = redis.Redis(host=host, port=port, password=passwd)
client_deque = redis.Redis(host=host, port=port, password=passwd)
quene_name = 'test_queue'
t1 = threading.Thread(target=random_enqueue, args=(client_enque, quene_name))
t1.start()
t2 = threading.Thread(target=random_dequeue, args=(client_deque, quene_name))
t2.start()
def signal_handler(signal, frame):
print("You pressed Ctrl+C!")
global START_FLAG
START_FLAG = False
t1.join()
t2.join()
print('exit')
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGQUIT, signal_handler)
while True:
time.sleep(60)
if __name__ == '__main__':
main() |
AlexStocks
reviewed
Nov 24, 2023
| std::set<std::string> compact_dbs_; | ||
| }; | ||
|
|
||
| class CompactRangeCmd : public Cmd { |
Contributor
There was a problem hiding this comment.
非 Redis 指令而是作为Pika 内置指令的话, 建议改为 PkCompactRangeCmd
AlexStocks
reviewed
Nov 24, 2023
| const std::string kCmdNameAuth = "auth"; | ||
| const std::string kCmdNameBgsave = "bgsave"; | ||
| const std::string kCmdNameCompact = "compact"; | ||
| const std::string kCmdNameCompactRange = "compactrange"; |
Contributor
There was a problem hiding this comment.
建议改为 pkcompactrange,类似于 pksetatex pkrange,标明这是一个 pika 内置指令,区别于 redis 指令
Contributor
|
如果 把这个 Python 脚本改成 Go 很困难,那就把这个工具放到 github.com/OpenAtomFoundation/pika/tests/helpers 目录下,然后在 CompactRangeCmd 之上加上英文注释,说明下这个工具可以对这个命令进行功能测试 |
AlexStocks
approved these changes
Nov 27, 2023
bigdaronlee163
pushed a commit
to bigdaronlee163/pika
that referenced
this pull request
Jun 8, 2024
…nAtomFoundation#2163) * add new command: compactrange $db $type $start_key $end_key * update unused value * update test script about compactrange command --------- Co-authored-by: denghao.denghao <denghao.denghao@bigo.sg>
cheniujh
pushed a commit
to cheniujh/pika
that referenced
this pull request
Sep 24, 2024
…nAtomFoundation#2163) * add new command: compactrange $db $type $start_key $end_key * update unused value * update test script about compactrange command --------- Co-authored-by: denghao.denghao <denghao.denghao@bigo.sg>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref from #2119:
ref issue #2040