In September, the code quality was not high enough, and it was sprayed into a sieve by the boss. It has been repeatedly mentioned that high-quality code, maintenance, and high performance are required ......
Fortunately, during the last week, we finally got into short working hours and launched redis-land-go in gray scale. The project also changed to redis-persist, where GitHub was located.
Previously Implemented interfaces from redis to leveldb and Skynet to read data from leveldb. The last week added functions that may be used by SA colleagues. Mainly:
- Dump
- Restore_one
- Restore_all
- Sync
- Sync_all
- Count
- Diff
- Keys
- Check_all
- Fast_check
These commands can be divided into three types: Copy commands from redis to leveldb, such as commands starting with sync, and copy commands starting with restore from leveldb to redis; the rest is used to check the data on both sides, such as checking the diff of a player data, checking the count of the number, and listing the keys of the leveldb player uid
Fast_check is a special optimization for the current player storage. In leveldb, a special key table is prefixed with the key-value pair of the player UID-player data version. This table is small enough and can be put into the memory. Therefore, when you only need to compare the data version, it can be completed in a very short time. When redis and leveldb are connected over the network and are not on one machine, the data volume of million data cannot exceed 1 minute.
At the same time, I also looked at the leveldb structure while tossing this tool. Leveldb has the sstable concept. sstable is a table in the memory sorted by keys. It can be changed to memtable, and another table is to be written to the disk, sstable. When there is a small amount of data, the level is also relatively small. The specific LDB file corresponds to which key range, which is recorded in manifest. The written records are first recorded in the log. This is sequential writing, so it is extremely fast. Then, sort the data in the background regularly and combine the existing LDB files on the sstable and disk to make the data on the disk more and more orderly.
Redis-persist went live