Ranking list determination method and device

By combining Redis's ordered sets and relational databases, the performance bottleneck of ranking management in large-scale user scenarios is resolved, efficient and stable ranking updates and storage are achieved, storage costs are reduced, and the real-time and accuracy of data are ensured.

CN120631936APending Publication Date: 2025-09-12ABC FINANCIAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510752732.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

In existing technologies, frequent sorting operations in large-scale user scenarios lead to performance bottlenecks in relational databases, increase storage costs and waste resources.

Method used

Redis's ordered set is used to store and sort ranking data, with each user as an element and the number of invitations as a score. Offline rankings are updated regularly to reduce the number of database writes. Data consistency and stability are ensured through the combination of Redis and relational databases.

Benefits of technology

It reduces the storage cost caused by frequent writing, improves the efficiency and stability of ranking determination, reduces resource waste, and ensures the real-time and accuracy of the ranking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631936A_ABST
    Figure CN120631936A_ABST
Patent Text Reader

Abstract

The invention discloses a ranking list determination method and device which can be applied to the field of data processing, and the method comprises the steps that ranking list data are efficiently stored and ranked through an ordered set of Redis, each user serves as an element, and the invitation amount of each user serves as a score. When each preset updating time is satisfied, whether the invitation amount information of the target user is changed or not is checked. If the current ranking information changes, the ranking of the target user is recalculated according to the new invitation quantity information, and the offline ranking list is dynamically updated to ensure that the updated ranking list can accurately reflect the current ranking information of the user. Namely, the ranking list is stored through redis, and before the next timed task is executed, the ranking list is kept unchanged, so that the write-in frequency of the database can be reduced, the storage cost caused by frequent write-in is reduced, and resource waste is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a ranking determination method and device. Background Art

[0002] In today's internet applications, leaderboards are a crucial component of many platforms, such as gaming, social networking, and e-commerce platforms. Leaderboards encourage user participation and interaction, enhancing the user experience. However, as the number of users continues to grow, managing and updating leaderboards presents numerous technical challenges.

[0003] Existing technologies primarily implement ranking functions through relational databases or in-memory databases. Relational databases (such as MySQL) generate rankings by periodically querying and sorting data using SQL statements. While these databases offer strong data persistence and complex query capabilities, frequent sorting operations can lead to performance bottlenecks in large-scale user scenarios, impacting system responsiveness, increasing storage costs, and wasting system resources.

[0004] Therefore, how to reduce the number of writes to the database, reduce the storage cost caused by frequent writes, and avoid waste of resources is a technical problem that those skilled in the art urgently need to solve. Summary of the Invention

[0005] The present application provides a ranking determination method to reduce the number of writes to a database, lower the storage cost caused by frequent writes, and avoid waste of resources. The present application also provides a ranking confirmation device.

[0006] In a first aspect, the present application provides a ranking determination method, comprising:

[0007] Get ranking data;

[0008] The ranking data is sorted using an ordered set of a remote dictionary service, Redis, where each element in the ordered set represents a user, and the score of the element represents the user's ranking basis, and the elements are sorted from high to low according to the score;

[0009] Generate offline rankings based on the sorting results;

[0010] When a preset update time is met and the invitation quantity information of the target user in the offline ranking list changes, determining the current ranking information of the target user in the offline ranking list according to the invitation quantity information;

[0011] The offline ranking list is updated according to the current ranking information to obtain a target ranking list.

[0012] Optionally, the method further includes: storing the target ranking list in a preset relational database.

[0013] Optionally, the method further includes:

[0014] Verifying the target ranking list stored in the relational database at predetermined intervals;

[0015] If the target ranking list stored in the relational database is inconsistent with the target ranking list stored in the redis, the target ranking list stored in the relational database is repaired.

[0016] Optionally, the method further includes:

[0017] When the target ranking list stored in redis is lost, query and sort are performed according to the target ranking list stored in the relational database.

[0018] Optionally, the method further includes:

[0019] Testing the performance indicators of Redis and the relational database, including response time, resource utilization, and error rate;

[0020] When any one of the performance indicators meets the alarm condition, an alarm message is issued.

[0021] In a second aspect, the present application further provides a ranking confirmation device, the device comprising:

[0022] Acquisition unit, used to obtain ranking data;

[0023] A sorting unit, configured to sort the ranking data using an ordered set of a remote dictionary service Redis, wherein each element in the ordered set represents a user, and the score of the element represents the user's ranking basis, and the elements are sorted from high to low according to the score;

[0024] A generation unit, used to generate an offline ranking list based on the sorting results;

[0025] a first updating unit, configured to determine, when a preset update time is met and the invitation quantity information of the target user in the offline ranking list changes, the current ranking information of the target user in the offline ranking list according to the invitation quantity information;

[0026] The second updating unit is configured to update the offline ranking list according to the current ranking information to obtain a target ranking list.

[0027] Optionally, the device further includes:

[0028] The storage unit is used to store the target ranking list in a preset relational database.

[0029] Optionally, the device further includes:

[0030] a verification unit, configured to verify the target ranking list stored in the relational database at predetermined intervals;

[0031] A repairing unit is configured to repair the target ranking list stored in the relational database if the target ranking list stored in the relational database is inconsistent with the target ranking list stored in the redis.

[0032] Optionally, the device further includes:

[0033] The query unit is used to query and sort the target rankings stored in the relational database when the target rankings stored in redis are lost.

[0034] Optionally, the device further includes:

[0035] A detection unit, configured to detect performance indicators of Redis and the relational database, wherein the performance indicators include response time, resource utilization, and error rate;

[0036] The alarm unit is used to issue an alarm message when any one of the performance indicators meets the alarm condition.

[0037] In a third aspect, an embodiment of the present application provides a device comprising a memory and a processor, wherein the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the method described in the first aspect above.

[0038] In a fourth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a code. When the code is executed, the device executing the code implements the method described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the following briefly introduces the drawings required for use in the embodiment or the prior art description. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0040] Figure 1 A flowchart of a ranking determination method provided in an embodiment of the present application;

[0041] Figure 2 A schematic structural diagram of a specific embodiment of the ranking confirmation device provided by this application;

[0042] Figure 3 This is an interface diagram of a ranking list provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of this application.

[0044] It should be noted that the present application provides a ranking determination method and apparatus for use in a ranking determination application scenario in the field of data processing. The above is merely an example and does not limit the application fields of the method and apparatus provided in the present application.

[0045] In today's internet applications, leaderboards are a crucial component of many platforms, such as gaming, social networking, and e-commerce platforms. Leaderboards encourage user participation and interaction, enhancing the user experience. However, as the number of users continues to grow, managing and updating leaderboards presents numerous technical challenges.

[0046] Existing technologies primarily implement ranking functions through relational databases or in-memory databases. Relational databases (such as MySQL) generate rankings by periodically querying and sorting data using SQL statements. While these databases offer strong data persistence and complex query capabilities, frequent sorting operations can lead to performance bottlenecks in large-scale user scenarios, impacting system responsiveness, increasing storage costs, and wasting system resources.

[0047] In view of this, the present application provides a ranking determination method, which utilizes Redis's ordered sets to efficiently store and sort ranking data, where each user is an element and its invitation quantity is a score. When each preset update time is met, the present application will check whether the invitation quantity information of the target user has changed. If it has changed, the ranking of the target user will be recalculated based on the new invitation quantity information, and the offline ranking will be dynamically updated to ensure that the updated ranking can accurately reflect the user's current ranking information. That is, the present application uses redis to store the rankings, and the rankings remain unchanged before the next scheduled task is executed. This can reduce the number of writes to the database, reduce the storage cost caused by frequent writes, and avoid waste of resources.

[0048] The method provided in the embodiments of the present application may be executed by software on a computing device, such as a mobile phone, tablet computer, or computer.

[0049] In order to make the technical personnel in this field better understand the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods. The following description is made by taking the method provided in the embodiment of the present invention as an example executed by a computing device.

[0050] Figure 1 This is a flowchart of a ranking determination method provided in an embodiment of the present application. Figure 1 As shown, the method includes:

[0051] S101: Obtain ranking data.

[0052] The computing device can access leaderboard data, which is a list that ranks and displays user activity participation according to specific rules. In sharing fission activities, leaderboards are typically ranked based on factors such as the number of user invites, activity completion rate, and activity level to encourage user participation and sharing.

[0053] S102: Sort the ranking data using the ordered set of Redis.

[0054] The computing device uses Redis's ordered set to sort the ranking data. Redis is an open source, memory-based, high-performance key-value storage database. Each element in the Redis ordered set represents a user, and the element's score represents the user's ranking basis. The elements are sorted from high to low according to the score.

[0055] For example, each user can be stored as an element in an ordered set, where the user's unique identifier (such as the user ID) is the member, and the user's ranking (such as points, number of invitations, etc.) is the score. After adding the user data to the ordered set, Redis can automatically sort all elements according to the score, with elements with higher scores at the front and elements with lower scores at the back.

[0056] In some possible implementations, this sorting can be real-time; whenever new user data is added or updated, Redis automatically recalculates and adjusts the sorting. To retrieve leaderboard data, you can use the ZREVRANGE command, specifying the start and end indexes (e.g., 0-1 to retrieve the entire leaderboard), and append the WITHSCORES option to retrieve the user's score as well. This way, you can retrieve the complete leaderboard data in descending order of score, enabling efficient, real-time leaderboard queries.

[0057] In addition, when the user's ranking basis changes, the score of the corresponding element in the ordered set can be updated through the ZADD command. Redis will automatically adjust the user's ranking position to ensure that the ranking data is always kept up to date.

[0058] In some possible implementations, in order to support large-scale user participation and highly concurrent ranking access, the embodiments of the present application can design a redis tree structure. This structure can distribute data across multiple Redis instances through sharding technology, thereby improving the scalability and fault tolerance of the system. Each shard is responsible for maintaining the ranking information of a portion of users, so that even if a shard fails, other shards can continue to work to ensure service continuity. The distributed design also allows the system to dynamically increase or decrease the number of shards based on load conditions, allowing the system to flexibly respond to different traffic demands.

[0059] S103: Generate an offline ranking list based on the sorting results.

[0060] The computing device generates an offline ranking list based on the sorting results.

[0061] For example, the computing device can periodically (every preset time period, such as one week) obtain data that has been sorted by score (such as user points, number of invitations, etc.) from the ordered set of Redis. These data will be organized into an offline ranking list. Between two scheduled tasks, this offline ranking list remains unchanged, thereby reducing the need for real-time data sorting and reducing the system load. When a user requests to view the ranking list, the computing device directly returns the pre-generated offline ranking list data, ensuring a quick response while avoiding performance issues caused by frequent access and sorting of large amounts of data.

[0062] S104: When the invitation quantity information of the target user in the offline ranking list changes within a preset update time, determine the current ranking information of the target user in the offline ranking list according to the invitation quantity information.

[0063] When the preset update time is met and the invitation quantity information of a target user in the offline ranking list changes, the computing device can first obtain the latest invitation quantity data of the user. Then, by comparing it with the current ranking data stored in Redis, the user's ranking is recalculated. That is, a scheduled task is executed every preset time (for example, 3 days, one week, etc.) to update the offline ranking list. The computing device updates the score of the user in the Redis ordered set according to the new invitation quantity, and uses the sorting function of Redis to automatically adjust the position of the user in the ranking list. Finally, the system synchronizes the updated ranking information to the offline ranking list to ensure that the offline ranking list can accurately reflect the current ranking of the target user. Before the next execution of the scheduled task, the offline ranking list remains unchanged. This mechanism not only ensures the real-time nature of the ranking list, but also avoids frequent updates to the entire ranking list data, thereby reducing the number of writes to Redis in the database and reducing the storage cost caused by frequent writes. The efficiency and stability of the ranking list determination are improved.

[0064] In some possible implementations, although Redis provides fast access speeds, its data persistence in memory is not as good as traditional disk storage. To this end, in an embodiment of the present application, the data in Redis can be synchronized in real time to a relational database, such as MySQL or PostgreSQL. This not only ensures the persistent storage of data, but also makes it possible to perform complex queries and data analysis. The synchronization process can be implemented by writing custom scripts or using existing database synchronization tools. It is important to ensure that the synchronization mechanism has high reliability and failover capabilities to prevent data loss.

[0065] S105: Update the offline ranking list according to the current ranking information to obtain a target ranking list.

[0066] The computing device can update the offline ranking list based on the current ranking information to obtain the final target ranking list.

[0067] In some possible implementations, in order to ensure data consistency between Redis and the relational database, embodiments of the present application may verify the target ranking list stored in the relational database at preset intervals.

[0068] If the target ranking list stored in the relational database is inconsistent with the target ranking list stored in Redis, the target ranking list stored in the relational database is repaired.

[0069] This involves periodically (for example, once a week) comparing the datasets in Redis and the relational database. During this comparison, the shards check the position of the full data in the offline ranking information to ensure the accuracy of all ranking information. If a data inconsistency is discovered, the computing device can immediately trigger an exception handling process. This process first attempts to automatically fix the error using a pre-set anomaly detection and repair algorithm. If the automatic repair fails, the system administrator can be notified for manual intervention to ensure data consistency and system stability.

[0070] In some possible implementations, when an exception occurs or the Redis cache is lost, resulting in the inability to find the ranking information in Redis, the embodiment of the present application can start an emergency recovery mechanism. Priority is given to querying the ranking information such as the number of invitations of all users from the relational database, and sorting according to this information to regenerate the Redis rankings. In this way, the ranking data can be restored in a relatively short time to ensure the continuity of the service and the availability of the data. After recovery, the ranking data can be further improved and optimized based on the user's invitation volume update and data sharding query mechanisms to maintain the accuracy and real-time nature of the data.

[0071] In some possible implementations, in order to allow users to easily view their rankings and historical changes, this application implements a ranking interface that can also be presented, such as Figure 2 As shown in the figure, this interface communicates with the backend service via an API, displaying user ranking information in real time. Users can use this interface to query their own points history and compare their rankings with other users. This ensures that the information displayed is both intuitive and easy to use.

[0072] In some possible implementations, to ensure stable operation, embodiments of the present application may also monitor the performance indicators of Redis and relational databases. These indicators include response time, resource utilization, and error rate. When any of these indicators meets an alarm condition, such as response time exceeding a set maximum value, resource utilization approaching full capacity, or error rate exceeding an allowable range, an alarm message is issued. This allows potential performance issues to be identified, helping operations personnel quickly locate and resolve faults.

[0073] This application utilizes Redis's ordered sets to efficiently store and sort ranking data, where each user is an element and their invitation count is a score. When each preset update time is met, this application will check whether the target user's invitation count information has changed. If it has changed, the target user's ranking will be recalculated based on the new invitation count information, and the offline ranking will be dynamically updated to ensure that the updated ranking can accurately reflect the user's current ranking information. That is, this application uses Redis to store the rankings, and the rankings remain unchanged before the next scheduled task is executed. This can reduce the number of writes to the database, reduce the storage cost caused by frequent writes, and avoid waste of resources.

[0074] The above are some specific implementations of the ranking determination method provided in the embodiments of this application. Based on this, this application also provides a corresponding device. The following will introduce the device provided in the embodiments of this application from the perspective of functional modularization. The device and the ranking determination method described above can be used in conjunction with each other.

[0075] Figure 2 The structural block diagram of the ranking confirmation device provided by the embodiment of the present invention is referred to as the specific embodiment 2, and Figure 2 The apparatus may include:

[0076] An acquisition unit 200 is used to acquire ranking data;

[0077] A sorting unit 210 is configured to sort the ranking data using an ordered set of a remote dictionary service Redis, where each element in the ordered set represents a user, and the score of the element represents the user's ranking basis, and the elements are sorted from high to low according to the score;

[0078] A generating unit 220, configured to generate an offline ranking list based on the ranking results;

[0079] A first updating unit 230 is configured to determine the current ranking information of the target user in the offline ranking list according to the invitation quantity information when a preset update time is met and the invitation quantity information of the target user in the offline ranking list changes;

[0080] The second updating unit 240 is configured to update the offline ranking list according to the current ranking information to obtain a target ranking list.

[0081] Optionally, the device further includes:

[0082] The storage unit is used to store the target ranking list in a preset relational database.

[0083] Optionally, the device further includes:

[0084] a verification unit, configured to verify the target ranking list stored in the relational database at predetermined intervals;

[0085] A repairing unit is configured to repair the target ranking list stored in the relational database if the target ranking list stored in the relational database is inconsistent with the target ranking list stored in the redis.

[0086] Optionally, the device further includes:

[0087] The query unit is used to query and sort the target rankings stored in the relational database when the target rankings stored in redis are lost.

[0088] Optionally, the device further includes:

[0089] A detection unit, configured to detect performance indicators of Redis and the relational database, wherein the performance indicators include response time, resource utilization, and error rate;

[0090] The alarm unit is used to issue an alarm message when any one of the performance indicators meets the alarm condition.

[0091] The embodiments of the present application also provide corresponding devices and computer storage media for implementing the solutions provided by the embodiments of the present application.

[0092] The device includes a memory and a processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the method described in any embodiment of the present application.

[0093] The computer storage medium stores code, and when the code is executed, the device executing the code implements the method described in any embodiment of the present application.

[0094] The "first" and "second" in the names such as "first" and "second" (if any) mentioned in the embodiments of this application are only used as name identifiers and do not represent the first or second in order.

[0095] Through the description of the above embodiments, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above embodiment methods can be implemented by means of software plus a general hardware platform. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment or certain parts of the embodiments of the present application.

[0096] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiment. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment. Those of ordinary skill in the art can understand and implement it without paying any creative work.

[0097] The above description is merely an exemplary embodiment of the present application and is not intended to limit the scope of protection of the present application.

Claims

1. A ranking determination method, characterized in that: include: Get ranking data; The ranking data is sorted using an ordered set of a remote dictionary service, Redis, where each element in the ordered set represents a user, and the score of the element represents the user's ranking basis, and the elements are sorted from high to low according to the score; Generate offline rankings based on the sorting results; When a preset update time is met and the invitation quantity information of the target user in the offline ranking list changes, determining the current ranking information of the target user in the offline ranking list according to the invitation quantity information; The offline ranking list is updated according to the current ranking information to obtain a target ranking list.

2. The method according to claim 1, characterized in that The method further includes: storing the target ranking list in a preset relational database.

3. The method according to claim 1, characterized in that The method further comprises: Verifying the target ranking list stored in the relational database at predetermined intervals; If the target ranking list stored in the relational database is inconsistent with the target ranking list stored in the redis, the target ranking list stored in the relational database is repaired.

4. The method according to claim 1, wherein The method further comprises: When the target ranking list stored in redis is lost, query and sort are performed according to the target ranking list stored in the relational database.

5. The method according to claim 1, characterized in that The method further comprises: Testing the performance indicators of Redis and the relational database, including response time, resource utilization, and error rate; When any one of the performance indicators meets the alarm condition, an alarm message is issued.

6. A ranking determination device, characterized in that: include: Acquisition unit, used to obtain ranking data; A sorting unit, configured to sort the ranking data using an ordered set of a remote dictionary service Redis, wherein each element in the ordered set represents a user, and the score of the element represents the user's ranking basis, and the elements are sorted from high to low according to the score; A generation unit, used to generate an offline ranking list based on the sorting results; a first updating unit, configured to determine, when a preset update time is met and the invitation quantity information of the target user in the offline ranking list changes, the current ranking information of the target user in the offline ranking list according to the invitation quantity information; The second updating unit is configured to update the offline ranking list according to the current ranking information to obtain a target ranking list.

7. The device according to claim 6, characterized in that The device further comprises: The storage unit is used to store the target ranking list in a preset relational database.

8. The device according to claim 6, characterized in that The device further comprises: a verification unit, configured to verify the target ranking list stored in the relational database at predetermined intervals; A repairing unit is configured to repair the target ranking list stored in the relational database if the target ranking list stored in the relational database is inconsistent with the target ranking list stored in the redis.

9. The device according to claim 6, characterized in that The device further comprises: The query unit is used to query and sort the target rankings stored in the relational database when the target rankings stored in redis are lost.

10. The device according to claim 6, characterized in that The device further comprises: A detection unit, configured to detect performance indicators of Redis and the relational database, wherein the performance indicators include response time, resource utilization, and error rate; The alarm unit is used to issue an alarm message when any one of the performance indicators meets the alarm condition.

Citation Information

Cited By

  • Internet of Things equipment state detection and notification method and device based on Redis multi-data structure collaboration and electronic equipment

    CN121984896A