Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Java rewriting redis server

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Background

Recently, I studied the protocol, persistence strategy and single-threaded model of redis, and suddenly felt that it matched java very well. Source code, please poke here hard.

Purpose

In view of the fact that redis is written in c, it is difficult for java's classmates to read, so they write the java version. Let more developers understand the essence of high-performance design, while deepening the understanding of underlying transmission, storage, and indexing.

Feature 1. Compatible with most redis native protocols 2. Compatible with redis desktop client 0.9. 3. Db partition isolation and transaction mechanism 4. Advanced features: such as blocking queues, publish subscriptions 5. Data persistence uses jdk native MappedByteBuffer synchronous flushing disk (virtual memory technology) 6. Key,value storage isolation, only key space occupies virtual machine memory, and value is only loaded when it is used, so it is better than redis7. Compatible with benchmark testing of common redis java client tools such as jedis,spring-data-redis,spring-boot-data

Stand-alone (4-core 8g), 1000 connection, random value set,tps is about 3W +

Referring to the figure below, 16379 is jredis,7003 and redis

Storage design jredis file structure

The default is 8 partitions, which is equivalent to 8 db. Data is written synchronously while the program is running, and restart will automatically read the recovered data into memory.

Db file content

It is divided into one key area + three value type areas, and the corresponding disk file structure is as follows:

Detailed description of the document

The key area loads key for all value types

The value area only loads values of the same type

Buffer design

Linear storage, custom message format, fixed message length, a maximum storage of 1024 bytes per unit. Dynamic expansion is not supported for the time being when files are full.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report