Home >Technology peripherals >It Industry >A new version of WeChat's full-platform terminal database WCDB is open source, with new support for C++ and Kotlin
News on April 9th, WCDB is a terminal database based on SQLite open sourced by the WeChat team. Since it was open sourced in June 2017, more than ten versions have been launched.
As one of the most frequently used apps in China and even around the world, WeChat internally covers databases for various businesses, and the number of stored messages can reach millions or even tens of millions. This huge amount of data and increasingly rich application scenarios have brought constantly updated needs and challenges to WCDB, and the original code framework has gradually become difficult to cope with.
Therefore, starting from 2019, WeChat decided to abandon the backward compatibility of the interface and make every effort to create a more powerful new version of WCDB. After multiple iterations, WCDB's interface layer and core logic layer have been comprehensively improved, and many new features have also been accumulated.
Now, WeChat announced that the new version of WCDB, which has been majorly upgraded, will be open source. The main changes and updates include:
Richer development language Support: New support for C, complete support for Java and Kotlin language ORM, covering more terminal platforms;
More powerful SQL expression capabilities: Winq has been rewritten, Strengthening, etc.;
More secure data storage capabilities: new data backup solutions, repair solutions, etc.;
More flexible data expansion capabilities : Data migration, data compression, etc.;
More detailed performance optimization capabilities: FTS5 optimization, interruptible transactions, etc.
WCDB version 1.0 supports three development languages: Objective-C, Swift, and Java. Except for the three languages of WCDB, they share the same version of SQLite and the same set of backup and repair logic. The code is all developed independently.
As WCDB continues to iterate, many of WCDB's new capabilities have been developed and verified online on the ObjC version. The Swift and Java versions are basically in a state of stopping iteration, and the differences between them are getting bigger and bigger. . In an ideal state, WCDB in different language versions should have the same capabilities. However, if the new logic of the ObjC version is re-implemented in Swift and Java, it will not only be a heavy workload, but also prone to errors. It will need to be verified online again, which is not very good. Reality.
Fortunately, The core logic of the ObjC version of WCDB is implemented in C, and ObjC is only used to implement the logic of the interface layer. Many libraries that support multiple development languages use C language to implement core logic, and other languages are only used to implement the interface layer, such as the very popular client-side NoSQL database component realmDB. WCDB can also be designed according to this idea, so that the ObjC version of WCDB only needs minor adjustments, and the core logic is completely implemented in C. Swift and Java access the C core logic through the bridging method.
In addition, in order to fully support the database development needs of different scenarios on each side of WeChat, WCDB has also expanded its support for C and Kotlin, thus fully covering the current mainstream languages for terminal development.
At the interface level, the new version of WCDB fully supports the five major terminal development languages C, Java, Kotlin, Swift and ObjC, covering The four major terminal platforms are Android, iOS, Windows and Linux. At the same time, WeChat has also rewritten and strengthened Winq, enabling developers to write arbitrary SQL using native syntax in various languages.
At the functional level, the new version of WCDB has launched a new data backup and repair solution, which improves the data repair rate and reduces the performance consumption of data backup to negligible.
In addition, WeChat has also launched two new functions: data migration and data compression, allowing developers to deal with the two major problems of excessive data aggregation and excessive data expansion in complex businesses through simple configuration. . The new version of WCDB also introduces new features such as FTS5 optimization and interruptible transactions, allowing developers to achieve more extreme performance optimization in specific scenarios.
The new version of WCDB has been open sourced on Github. The project address is attached to this site:
https://github.com/Tencent/wcdb
The above is the detailed content of A new version of WeChat's full-platform terminal database WCDB is open source, with new support for C++ and Kotlin. For more information, please follow other related articles on the PHP Chinese website!