Redis源码剖析之持久化(4)

def rewrite_list(key):
                # 使用LRANGE命令获取列表键包含的所有元素
                item1,item2,...,itemN = LRANGE(key,0,-1)

# 使用RPUSH命令重写列表键
                f.write_command(RPUSH,key,item1,item2,....,itemN)

def rewrite_hash(key):
                field1,value1,field2,value2,...,fieldN,valueN = HGETALL(key)
                f.write_command(HSET,key,field1,value1,field2,value2,...,fieldN,valueN)

def rewrite_set(key):
                elem1,elem2,...,elemN = SMEMBERS(key)
                f.write_command(SADD,key,elem1,elem2,...,elemN)

def rewrite_sorted_set(key):
                member1,score1,member2,score2,...,memberN,scoreN = ZRANGE(key,0,-1,"WITHSCORES")
                f.write_command(member1,score1,member2,score2,...,memberN,scoreN)

def rewrite_expire_time(key):
                timestamp = get_expire_time_in_unixstamp(key)
                f.write_command(pexpireat,key,timestamp)

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/0d33737369a96d387949bb8541a74607.html