CN116048834A - Method, device and storage medium for updating integrated ranking list in real time - Google Patents

Method, device and storage medium for updating integrated ranking list in real time Download PDF

Info

Publication number
CN116048834A
CN116048834A CN202211462692.2A CN202211462692A CN116048834A CN 116048834 A CN116048834 A CN 116048834A CN 202211462692 A CN202211462692 A CN 202211462692A CN 116048834 A CN116048834 A CN 116048834A
Authority
CN
China
Prior art keywords
user
time
updating
ranking list
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211462692.2A
Other languages
Chinese (zh)
Inventor
舒伟
郭曼丽
陈荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Xinyu Network Technology Co ltd
Original Assignee
Guangzhou Xinyu Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Xinyu Network Technology Co ltd filed Critical Guangzhou Xinyu Network Technology Co ltd
Priority to CN202211462692.2A priority Critical patent/CN116048834A/en
Publication of CN116048834A publication Critical patent/CN116048834A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method, a device and a storage medium for updating an integrated ranking list in real time, wherein the method comprises the following steps: receiving an integral updating event triggered by a first user, and calculating the consumption integral of the integral updating event in a multithreading manner, and updating user data and ranking list data of the first user according to the consumption integral to generate a first ranking list; iteratively detecting whether a first user has a newly triggered integral updating event in a first preset time after the current integral time according to the current integral time, and updating user data of the first user according to the newly triggered integral updating event when each time of the newly triggered integral updating event exists until the first user is detected that the first user does not have the newly triggered integral updating event in the first preset time after the current integral time; and updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so that the final ranking list is displayed on the client of the first user, and the integrated ranking list is updated in real time.

Description

Method, device and storage medium for updating integrated ranking list in real time
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, and a storage medium for updating an integral ranking list in real time.
Background
The user obtains corresponding points in the APP through completing the appointed task, and a ranking list is generated after statistics of the points obtained by the user in an accumulated mode. The ranking list can enable the user to know the position of the user, mobilize the participation of the user and increase the viscosity of the user. In the daily operation process, the order of influencing the ranking list data of part of users in malicious point brushing behaviors can appear.
At present, the background regularly reads the integral data of all users from the database, sorts the integral data according to the integral size and the time for reaching the integral, eliminates invalid user data according to a list filtering list, thereby obtaining the final user ranking, and caches the ranking list result calculated at the next time. Whether the integral of the user changes or not, the data of all the users are needed to be read at regular time to calculate the integral and reorder, so that a plurality of unnecessary calculations are performed, and the service performance is wasted; as the user volume increases and the channel and form of obtaining points increases, the pressure of sequencing in the database becomes larger and larger, the time for updating the user ranking becomes longer as the user volume is larger, and the user ranking cannot be updated in real time; for malicious point-brushing behaviors of the user, the malicious point-brushing behaviors of the user cannot be automatically judged, and user data can be manually removed only according to a list filtering list.
Disclosure of Invention
The invention provides a method, a device and a storage medium for updating an integral ranking list in real time, which are used for realizing the real-time updating of the integral ranking list and ensuring the accuracy of data updating while improving the service performance by parallel processing of integral updating events.
The embodiment of the invention provides a method for updating an integrated ranking list in real time, which comprises the following steps:
receiving an integral updating event triggered by a first user, and calculating consumption integral of the integral updating event in a multithreading manner, and updating user data and ranking list data of the first user according to the consumption integral to generate a first ranking list; the point updating event is triggered and generated according to the fact that the first user operates at a client to enable the point to change; the user data includes integral data and an integral time; the ranking list data comprises integral data and ranking data of all users;
iteratively detecting whether a new triggered integral updating event exists in a first preset time after the current integral time or not by the first user according to the current integral time, and updating user data of the first user according to the new triggered integral updating event when the new triggered integral updating event exists each time until the fact that the new triggered integral updating event does not exist in the first preset time after the current integral time is detected;
And updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so as to display the final ranking list on the client of the first user.
As a preferred scheme, when a first user operates at a client to change the points, receiving a point update event triggered by the first user, updating user data and ranking list data of the first user, and realizing real-time updating of the ranking list.
Because the user point update is triggered by the event message, a plurality of point update events are required to be processed asynchronously and concurrently by the multi-thread of the ranking list background service, and the overall performance and the event processing capability of the ranking list background service are improved by the increase of the cooperative range of the plurality of processing events. In order to solve the problem that concurrency conflict occurs when the ranking list is updated after a plurality of point update events are processed in a multithread mode in a concurrent mode by the ranking list background service, whether a newly triggered point update event exists in a first preset time after the current point time is detected through iteration, after the fact that a new point update event does not exist in the first preset time after the last point time of the first user is detected, the ranking list is updated according to updated user data, the problem that ranking list data update is inaccurate due to the fact that the ranking list data are updated due to the fact that the same user ranking is updated in a concurrent mode at the same time is avoided, service performance is improved through parallel processing of the events, and meanwhile accuracy of data update is guaranteed.
As a preferred scheme, the multithreading calculates the consumption point of the point update event, updates the user data and the ranking list data of the first user according to the consumption point, and generates a first ranking list, which specifically includes:
updating user data of a first user once every time a consumption point is calculated, and judging the type of the first user according to a point updating event;
if the type of the first user is old, ranking the initial ranking list data through bit operation to generate a first ranking list;
if the type of the first user is a new user, adding the ranking list data of the new user into the initial ranking list data in a Zadd mode to generate a first ranking list;
the user data is stored in Red is in a Hash structure; one user corresponds to user data of one Hash structure; the leaderboard data is stored in a Zset structure in Red is.
In the preferred scheme, in the process of calculating the consumption points of the point updating event through multithreading, each time a consumption point is calculated, user data and ranking list data of a first user are updated, ranking is carried out on the ranking list data of an initial user through modifying ranking list data of the initial user and carrying out ranking through bit operation, ranking list data of a new user is added to the initial ranking list in a Zadd mode, performance of a Red is Zset structure is utilized, ranking is carried out on each element in the Zset, calculation of the ranking of the user points by background service is reduced, and calculation pressure of Mysql and a back-end process is reduced.
Preferably, according to the current integration time, before iteratively detecting whether the first user has a newly triggered integration update event in a first preset time after the current integration time, the method further includes:
adding a delay event of the first user in a delay queue of Red is according to the current integration time of the first user; the delay event delays sending an update message for a first preset time after the current integration time; a user corresponds to a delay event identified by i d of the user.
As a preferred scheme, adding a corresponding delay event of a user in a delay queue of Red is, delaying an update message of updating the ranking list data sent by a preset time after the current integration time by the event to judge whether a new integration update event exists in the preset time after the current integration time, judging whether the integration of the same user in the preset time is changed or not, and if the integration is changed, causing concurrent conflict when updating the ranking list after the multithread asynchronous concurrent processing of a plurality of integration update events by a ranking list background service, updating the corrected ranking list after a certain time is needed; on the one hand, whether uninterrupted integral change exists for the same user or not can be judged, and if the uninterrupted integral change occurs in a second preset time, the user is an abnormal user; on the other hand, the problem that the update of the ranking list data is inaccurate due to the reasons of a network and the like when the ranking of the same user is updated simultaneously at the same time can be avoided, and the accuracy of the data update is ensured while the service performance is improved by parallel processing of events.
Preferably, when a new triggered integral updating event exists each time, updating the user data of the first user according to the new triggered integral updating event until the first user is detected that the new triggered integral updating event does not exist in a first preset time after the current integral time, specifically:
if detecting that a first user has a newly triggered integration update event in a first preset time after the current integration time, recording the current integration time as an initial integration time, and updating integration data and integration time in user data; updating the delay event of the first user according to the updated integration time, so that the delay event delays for a first preset time to send an update message after the updated integration time;
and receiving an update message sent by the first user after the latest delay event of the first user is delayed by the first preset time after the latest integration time until the first user does not generate a new integration update event in the first preset time after the latest integration time.
When detecting that a new triggered point update event exists in a first preset time after the current point time, the delay event needs to be updated according to the updated point time, so that the delay event delays an update message of updating the ranking list data sent by the preset time after the updated point time, namely when the point update event occurs, a new delay event is generated to cover an old delay event, the time of the sent update message of updating the ranking list data is continued, until the first user does not generate a new point update event in the first preset time after the latest point time, the update message sent by the first preset time after the latest point time of the latest delay event of the first user is received, the ranking list is updated again after the update message is received, the problem that the ranking list data is not updated accurately due to a network and the like when the same user ranking is updated simultaneously can be avoided, and the accuracy of the data update is ensured while the service performance is improved by the parallel processing event.
Preferably, until detecting that the first user does not have a newly triggered integration update event within a first preset time after the current integration time, the method further includes:
if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, judging that the first user is an abnormal user; and deleting the user data of the first user from the first ranking list.
As a preferred scheme, if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, namely, the user has uninterrupted brushing behavior in the second preset time, judging that the first user is an abnormal user; deleting the user data of the first user from the first ranking list, judging whether uninterrupted integral change exists for the same user, and if no update message is received within a second preset time from the initial integral time, namely the same user is an abnormal user when uninterrupted integral change occurs within the second preset time; the malicious point refreshing behavior of the user can be automatically judged through refreshing of the delay event, and the service performance of the ranking list background service is optimized.
As a preferred solution, the updating of the first ranking list is performed according to the updated user data of the first user, so as to obtain a final ranking list, which specifically includes:
after receiving the update message of the latest delay event, acquiring updated user data of the first user, modifying the ranking list data of the first ranking list according to the integral data and the integral time of the first user, and ranking the ranking list data through bit operation to acquire a final ranking list.
As a preferred scheme, whether the integral of the same user is changed in a preset time is judged, if the integral is changed, the problem that the update of the ranking list data is inaccurate due to the reasons of a network and the like when a plurality of integral update events are processed in a multithreading mode in a concurrent mode by the ranking list background service is possibly caused, the hash structure of the user data is updated in red is updated in a single thread event, and the influence of concurrent conflict is avoided, so that the user data is accurate, the ranking list is required to be corrected through the update of the user data after an update message is received, and the problem that the service performance is improved and the accuracy of data update is ensured when the service performance is improved in a concurrent process event when the ranking of the same user is simultaneously updated at the same moment can be avoided.
As a preferred solution, according to the current integration time, iteratively detecting whether the first user has a newly triggered integration update event in a first preset time after the current integration time, and further including:
and if the fact that the first user does not generate a new integral updating event in a first preset time after the current integral time is detected, the first ranking list is used as a final ranking list.
As a preferred scheme, if whether a new triggered point update event exists in a first preset time after the current point time is detected, the first ranking list is used as a final ranking list.
Correspondingly, the invention also provides a device for updating the integrated ranking list in real time, which comprises the following steps: an updating module and a correcting module;
the updating module is used for receiving an integral updating event triggered by a first user, calculating consumption integral of the integral updating event in a multithreading mode, updating user data and ranking list data of the first user according to the consumption integral, and generating a first ranking list; the point updating event is triggered and generated according to the fact that the first user operates at a client to enable the point to change; the user data includes integral data and an integral time; the ranking list data comprises integral data and ranking data of all users;
The correction module is used for iteratively detecting whether a new triggered integral updating event exists in a first preset time after the current integral time according to the current integral time, and updating user data of the first user according to the new triggered integral updating event when the new triggered integral updating event exists each time until the fact that the new triggered integral updating event does not exist in the first preset time after the current integral time is detected;
and updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so as to display the final ranking list on the client of the first user.
As a preferred scheme, when a first user operates at a client to change the score, an updating module receives a score updating event triggered by the first user, updates the user data and the ranking list data of the first user, and realizes the real-time updating of the ranking list.
Because the user point update is triggered by the event message, a plurality of point update events are required to be processed asynchronously and concurrently by the multi-thread of the ranking list background service, and the overall performance and the event processing capability of the ranking list background service are improved by the increase of the cooperative range of the plurality of processing events. In order to solve the problem that concurrency conflict occurs when the ranking list is updated after a plurality of point update events are processed in a multithread mode in a concurrent mode by the ranking list background service, a correction module detects whether a newly triggered point update event exists in a first preset time after the current point time through iteration, corrects the ranking list according to updated user data after detecting that the first user does not have the new point update event in the first preset time after the last point time, and avoids the problem that ranking list data update is inaccurate due to the fact that the ranking list data update is caused by the network and the like when the ranking list is updated in a concurrent mode at the same time.
As a preferred scheme, the updating module comprises a user data updating unit and a ranking list data updating unit;
the user data updating unit is used for updating the user data of the first user once every time a consumption point is calculated;
The ranking list data updating unit is used for judging the type of the first user according to an integral updating event every time a consumption integral is calculated;
if the type of the first user is old, ranking the initial ranking list data through bit operation to generate a first ranking list;
if the type of the first user is a new user, adding the ranking list data of the new user into the initial ranking list data in a Zadd mode to generate a first ranking list;
the user data is stored in Red is in a Hash structure; one user corresponds to user data of one Hash structure; the leaderboard data is stored in a Zset structure in Red is.
As a preferred scheme, in the process of calculating the consumption points of the point updating event in a multithreading manner, each time a consumption point is calculated, a user data updating unit updates user data of a first user and ranking list data of a ranking list data updating unit, ranking is carried out by modifying ranking list data of an initial user and carrying out bit operation, ranking list data of a new user is added to the initial ranking list in a Zadd mode, each element in Zset is ranked by utilizing the performance of a Red i Zset structure, calculation of the user point ranking by background service is reduced, and calculation pressure of Mysql and a back-end process is reduced.
Preferably, the correction module includes: the device comprises a delay event adding unit, a delay event updating unit and a ranking list correcting unit;
the delay event adding unit is used for adding the delay event of the first user in a delay queue of Red is according to the current integration time of the first user; the delay event delays sending an update message for a first preset time after the current integration time; a user corresponds to a delay event, and the delay event is identified by the id of the user;
the delay event updating unit is used for updating the integral data and the integral time in the user data if detecting that a newly triggered integral updating event exists in a first preset time after the current integral time of the first user; updating the delay event of the first user according to the updated integration time, so that the delay event delays for a first preset time to send an update message after the updated integration time;
until the first user does not generate a new integral update event in a first preset time after the latest integral time, receiving an update message sent by the first user in a first preset time after the latest delay event of the first user is delayed after the latest integral time;
The ranking list correction unit is used for acquiring updated user data of the first user after receiving the update message of the latest delay event, modifying ranking list data of the first ranking list according to the integral data and the integral time of the first user, and ranking the ranking list data through bit operation to acquire a final ranking list; if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, judging that the first user is an abnormal user; and deleting the user data of the first user from the first ranking list.
As a preferred scheme, adding a corresponding delay event of a user in a delay queue of Red is, delaying an update message of updating the ranking list data sent by a preset time after the current integration time by the event to judge whether a new integration update event exists in the preset time after the current integration time, judging whether the integration of the same user in the preset time is changed or not, and if the integration is changed, causing concurrent conflict when updating the ranking list after the multithread asynchronous concurrent processing of a plurality of integration update events by a ranking list background service, updating the corrected ranking list after a certain time is needed; on the one hand, whether uninterrupted integral change exists for the same user or not can be judged, and if the uninterrupted integral change occurs in a second preset time, the user is an abnormal user; on the other hand, the problem that the update of the ranking list data is inaccurate due to the reasons of a network and the like when the ranking of the same user is updated simultaneously at the same time can be avoided, and the accuracy of the data update is ensured while the service performance is improved by parallel processing of events. If the same user is subjected to uninterrupted integral change within a second preset time, the same user is an abnormal user; the malicious point refreshing behavior of the user can be automatically judged through refreshing of the delay event, and the service performance of the ranking list background service is optimized.
Accordingly, the present invention also provides a computer-readable storage medium including a stored computer program; the computer program controls the equipment with the computer readable storage medium to execute the method for updating the score ranking list in real time according to the content of the invention when running.
Drawings
FIG. 1 is a flowchart illustrating a method for updating an integrated leaderboard in real time according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an embodiment of a device for updating an integrated leaderboard in real time.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
Referring to fig. 1, a method for updating an integrated ranking list in real time according to an embodiment of the present invention includes steps S101-S103:
Step S101: receiving an integral updating event triggered by a first user, and calculating consumption integral of the integral updating event in a multithreading manner, and updating user data and ranking list data of the first user according to the consumption integral to generate a first ranking list; the point updating event is triggered and generated according to the fact that the first user operates at a client to enable the point to change; the user data includes integral data and an integral time; the ranking list data includes score data and ranking data for all users.
In this embodiment, after the first user participates in completing various tasks in the client app, the first user triggers a corresponding point update event, generates a point update event queue to store a plurality of point update events, and the ranking list service background stores multithreaded consumption events in the point update event queue. After each coroutine calculates the consumption score of a score updating event, updating the user data of the Hash structure and the ranking list data of the Zset structure stored in Red is.
In this embodiment, the multithreading calculates a consumption score of the score update event, updates the user data and the ranking list data of the first user according to the consumption score, and generates a first ranking list, which specifically includes:
updating user data of a first user once every time a consumption point is calculated, and judging the type of the first user according to a point updating event;
if the type of the first user is old, ranking the initial ranking list data through bit operation to generate a first ranking list;
if the type of the first user is a new user, adding the ranking list data of the new user into the initial ranking list data in a Zadd mode to generate a first ranking list;
the user data is stored in Red is in a Hash structure; one user corresponds to user data of one Hash structure; the leaderboard data is stored in a Zset structure in Red is.
In this embodiment, each time the leaderboard service process calculates a consumption score, user data requiring updating data in Red i s is read, the user data includes score data and score time, the leaderboard service process sends a hincr command to Red i s to update the score data of the corresponding user, and the last score time recorded in Hset is updated.
The leaderboard data is stored in Red is in a Zset structure, and comprises a Key and a score, wherein the Key is used for recording id of a user, and the score is used for recording integral data and integral time.
The leaderboards are ranked with score high and low, and in the same score case, users with early score times are ranked in front. score is a 64-bit floating point number with the structure 1 (sign bit) +11 (exponent bit) +52 (data bit). The lower 17 bits of score store the integration time to the remaining time of day 23:59:59, bits 18 to 53 store the user's integration data. The initial ranking list data is ranked by a bit operation, the high order stores the integral data, the low order stores the integral time, the higher the score is, the earlier the score is, and when the lower 17 bits of time are compared with the same time-sharing, the longer the time bit is, which means the earlier the time it reaches the score, so the score also needs to be ranked in front.
And when the user data is added to the leader board data of the Zset structure and is simultaneously sequenced internally, the client side only needs to read from the Zset according to the sequenced order when requesting the leader board, and the sequencing is not required to be repeated again in the service process.
Adding the ranking list data of the new user to the initial ranking list data in a Zadd mode, wherein the method specifically comprises the following steps:
Zadd is a data update operation provided by Red is Zset. And comparing the updated user data with the ranking list data, adding the user data of the user into the ranking list data if the user ids of the same user are not in the keys of the ranking list data, and updating the integral data and the integral time in the ranking list data score of the user ids according to the user data of the user if the user ids of the same user are in the keys.
Step S102: and iteratively detecting whether a new triggered integral updating event exists in a first preset time after the current integral time or not by the first user according to the current integral time, and updating the user data of the first user according to the new triggered integral updating event when the new triggered integral updating event exists each time until the fact that the new triggered integral updating event does not exist in the first preset time after the current integral time is detected by the first user.
In this embodiment, according to the current integration time, before iteratively detecting whether the first user has a newly triggered integration update event in a first preset time after the current integration time, the method further includes:
adding a delay event of the first user in a delay queue of Red is according to the current integration time of the first user; the delay event delays sending an update message for a first preset time after the current integration time; a user corresponds to a delay event identified by i d of the user.
In this embodiment, a delay event for updating the ranking list data after 2 seconds of the first user is added to the delay queue implemented by Red is, where the events are all unique identifiers formed by user ids. The delay event is delayed for 2 seconds after the current integration time to send an update message for updating the ranking list data, and when the ranking list service receives the update message, the ranking list is updated.
In this embodiment, when a new triggered integral update event exists each time, user data of the first user is updated according to the new triggered integral update event until it is detected that the first user does not have the new triggered integral update event within a first preset time after the current integral time, specifically:
if detecting that a first user has a newly triggered integration update event in a first preset time after the current integration time, recording the current integration time as an initial integration time, and updating integration data and integration time in user data; updating the delay event of the first user according to the updated integration time, so that the delay event delays for a first preset time to send an update message after the updated integration time;
And receiving an update message sent by the first user after the latest delay event of the first user is delayed by the first preset time after the latest integration time until the first user does not generate a new integration update event in the first preset time after the latest integration time.
In this embodiment, after the update message reaches the time, a process of the leaderboard service background reads the update message from the first delay queue, and the content of the update message includes: user id, updated list id, and operation type of updated leaderboard. The process writes the update message into a second delayed event queue that is consumed in parallel by the leaderboard service background.
In this embodiment, until it is detected that the first user does not have a newly triggered integral update event within a first preset time after the current integral time, the method further includes:
if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, judging that the first user is an abnormal user; and deleting the user data of the first user from the first ranking list.
In this embodiment, according to the current integration time, iteratively detecting whether the first user has a newly triggered integration update event in a first preset time after the current integration time, further includes:
And if the fact that the first user does not generate a new integral updating event in a first preset time after the current integral time is detected, the first ranking list is used as a final ranking list.
Step S103: and updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so as to display the final ranking list on the client of the first user.
In this embodiment, the updating of the first ranking list is performed according to the updated user data of the first user, so as to obtain a final ranking list, which specifically includes:
after receiving the update message of the latest delay event, acquiring updated user data of the first user, modifying the ranking list data of the first ranking list according to the integral data and the integral time of the first user, and ranking the ranking list data through bit operation to acquire a final ranking list.
In this embodiment, the ranking list service background reads the user data in Hash from Red is, and merges the user data into a ranking list in a high-low level mode again, adds the user data of the new user to the ranking list in a Zadd mode, and the ranking and integral data of the user on the ranking list are the final and correct data.
The implementation of the embodiment of the invention has the following effects:
when a first user operates at a client to change the points, receiving a point update event triggered by the first user, updating user data and ranking list data of the first user, and realizing real-time updating of the ranking list.
Because the user point update is triggered by the event message, a plurality of point update events are required to be processed asynchronously and concurrently by the multi-thread of the ranking list background service, and the overall performance and the event processing capability of the ranking list background service are improved by the increase of the cooperative range of the plurality of processing events. In order to solve the problem that concurrency conflict occurs when the ranking list is updated after a plurality of point update events are processed in a multithread mode in a concurrent mode by the ranking list background service, whether a newly triggered point update event exists in a first preset time after the current point time is detected through iteration, after the fact that a new point update event does not exist in the first preset time after the last point time of the first user is detected, the ranking list is updated according to updated user data, the problem that ranking list data update is inaccurate due to the fact that the ranking list data are updated due to the fact that the same user ranking is updated in a concurrent mode at the same time is avoided, service performance is improved through parallel processing of the events, and meanwhile accuracy of data update is guaranteed.
Example two
Referring to fig. 2, a device for updating an integrated ranking list in real time according to an embodiment of the present invention includes: an update module 201 and a correction module 202;
the updating module 201 is configured to receive a point update event triggered by a first user, calculate a consumption point of the point update event in a multithreading manner, update user data and ranking list data of the first user according to the consumption point, and generate a first ranking list; the point updating event is triggered and generated according to the fact that the first user operates at a client to enable the point to change; the user data includes integral data and an integral time; the ranking list data comprises integral data and ranking data of all users;
the correction module 202 is configured to iteratively detect, according to a current integration time, whether a new triggered integration update event exists in a first preset time after the current integration time, and update, according to the new triggered integration update event, user data of the first user when the new triggered integration update event exists each time, until it is detected that the new triggered integration update event does not exist in the first preset time after the current integration time; and updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so as to display the final ranking list on the client of the first user.
The updating module comprises a user data updating unit and a ranking list data updating unit;
the user data updating unit is used for updating the user data of the first user once every time a consumption point is calculated;
the ranking list data updating unit is used for judging the type of the first user according to an integral updating event every time a consumption integral is calculated;
if the type of the first user is old, ranking the initial ranking list data through bit operation to generate a first ranking list;
if the type of the first user is a new user, adding the ranking list data of the new user into the initial ranking list data in a Zadd mode to generate a first ranking list;
the user data is stored in Red is in a Hash structure; one user corresponds to user data of one Hash structure; the leaderboard data is stored in a Zset structure in Red is.
The correction module includes: the device comprises a delay event adding unit, a delay event updating unit and a ranking list correcting unit;
the delay event adding unit is used for adding the delay event of the first user in a delay queue of Red is according to the current integration time of the first user; the delay event delays sending an update message for a first preset time after the current integration time; a user corresponds to a delay event, and the delay event is identified by the id of the user;
The delay event updating unit is used for updating the integral data and the integral time in the user data if detecting that a newly triggered integral updating event exists in a first preset time after the current integral time of the first user; updating the delay event of the first user according to the updated integration time, so that the delay event delays for a first preset time to send an update message after the updated integration time;
until the first user does not generate a new integral update event in a first preset time after the latest integral time, receiving an update message sent by the first user in a first preset time after the latest delay event of the first user is delayed after the latest integral time;
the ranking list correction unit is used for acquiring updated user data of the first user after receiving the update message of the latest delay event, modifying ranking list data of the first ranking list according to the integral data and the integral time of the first user, and ranking the ranking list data through bit operation to acquire a final ranking list; if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, judging that the first user is an abnormal user; and deleting the user data of the first user from the first ranking list.
The device for updating the integral ranking list in real time can implement the method for updating the integral ranking list in real time in the embodiment of the method. The options in the method embodiments described above are also applicable to this embodiment and will not be described in detail here. The rest of the embodiments of the present application may refer to the content of the method embodiments described above, and in this embodiment, no further description is given.
The implementation of the embodiment of the invention has the following effects:
according to the device for updating the score ranking list in real time, when the first user operates at the client to change the score, the updating module receives the score updating event triggered by the first user, updates the user data and the ranking list data of the first user, and realizes the real-time updating of the ranking list.
Because the user point update is triggered by the event message, a plurality of point update events are required to be processed asynchronously and concurrently by the multi-thread of the ranking list background service, and the overall performance and the event processing capability of the ranking list background service are improved by the increase of the cooperative range of the plurality of processing events. In order to solve the problem that concurrency conflict occurs when the ranking list is updated after a plurality of point update events are processed in a multithread mode in a concurrent mode by the ranking list background service, a correction module detects whether a newly triggered point update event exists in a first preset time after the current point time through iteration, corrects the ranking list according to updated user data after detecting that the first user does not have the new point update event in the first preset time after the last point time, and avoids the problem that ranking list data update is inaccurate due to the fact that the ranking list data update is caused by the network and the like when the ranking list is updated in a concurrent mode at the same time.
Example III
Correspondingly, the invention further provides a computer readable storage medium, which comprises a stored computer program, wherein when the computer program runs, the equipment where the computer readable storage medium is located is controlled to execute the method for updating the score ranking list in real time according to any one of the embodiments.
The computer program may be divided into one or more modules/units, which are stored in the memory and executed by the processor to accomplish the present invention, for example. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions, which instruction segments are used for describing the execution of the computer program in the terminal device.
The terminal equipment can be computing equipment such as a desktop computer, a notebook computer, a palm computer, a cloud server and the like. The terminal device may include, but is not limited to, a processor, a memory.
The processor may be a central processing unit (Centra l Process i ng Unit, CPU), other general purpose processor, digital signal processor (Digita l Signa l Processor, DSP), application specific integrated circuit (App l icat i on Speci fic I ntegrated Ci rcuit, asic), field programmable gate array (Fie l d-Programmab l e Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, which is a control center of the terminal device, and which connects various parts of the entire terminal device using various interfaces and lines.
The memory may be used to store the computer program and/or the module, and the processor may implement various functions of the terminal device by running or executing the computer program and/or the module stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the mobile terminal, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory Card (Smart Med ia Card, SMC), secure Digital (SD) Card, flash Card (F1 ash Card), at least one disk storage device, flash memory device, or other volatile solid state storage device.
Wherein the terminal device integrated modules/units may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as stand alone products. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-On-y Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier wave signal, a telecommunications signal, a software distribution medium, and so forth.
The foregoing embodiments have been provided for the purpose of illustrating the general principles of the present invention, and are not to be construed as limiting the scope of the invention. It should be noted that any modifications, equivalent substitutions, improvements, etc. made by those skilled in the art without departing from the spirit and principles of the present invention are intended to be included in the scope of the present invention.

Claims (10)

1. A method for updating an integrated leaderboard in real time, comprising:
receiving an integral updating event triggered by a first user, and calculating consumption integral of the integral updating event in a multithreading manner, and updating user data and ranking list data of the first user according to the consumption integral to generate a first ranking list; the point updating event is triggered and generated according to the fact that the first user operates at a client to enable the point to change; the user data includes integral data and an integral time; the ranking list data comprises integral data and ranking data of all users;
iteratively detecting whether a new triggered integral updating event exists in a first preset time after the current integral time or not by the first user according to the current integral time, and updating user data of the first user according to the new triggered integral updating event when the new triggered integral updating event exists each time until the fact that the new triggered integral updating event does not exist in the first preset time after the current integral time is detected;
And updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so as to display the final ranking list on the client of the first user.
2. The method of claim 1, wherein the multithreading calculates a consumption score of the score update event, updates user data and leaderboard data of the first user according to the consumption score, and generates a first leaderboard, in particular:
updating user data of a first user once every time a consumption point is calculated, and judging the type of the first user according to a point updating event;
if the type of the first user is old, ranking the initial ranking list data through bit operation to generate a first ranking list;
if the type of the first user is a new user, adding the ranking list data of the new user into the initial ranking list data in a Zadd mode to generate a first ranking list;
wherein the user data is stored in Redis in a Hash structure; one user corresponds to user data of one Hash structure; the leaderboard data is stored in a set structure in Redis.
3. The method for updating the score ranking list in real time as claimed in claim 1, wherein the step of iteratively detecting whether the first user has a newly triggered score update event within a first predetermined time after the current score time according to the current score time further comprises:
adding a delay event of a first user in a delay queue of Redis according to the current integration time of the first user; the delay event delays sending an update message for a first preset time after the current integration time; a user corresponds to a delay event identified by the user's id.
4. The method for updating the score ranking list in real time as recited in claim 3, wherein each time a new triggered score update event exists, updating the user data of the first user according to the new triggered score update event until it is detected that the first user does not have a new triggered score update event within a first preset time after the current score time, specifically:
if detecting that a first user has a newly triggered integration update event in a first preset time after the current integration time, recording the current integration time as an initial integration time, and updating integration data and integration time in user data; updating the delay event of the first user according to the updated integration time, so that the delay event delays for a first preset time to send an update message after the updated integration time;
And receiving an update message sent by the first user after the latest delay event of the first user is delayed by the first preset time after the latest integration time until the first user does not generate a new integration update event in the first preset time after the latest integration time.
5. The method of claim 4, wherein the until the first user is detected that there is no newly triggered point update event within a first predetermined time after a current point time, further comprising:
if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, judging that the first user is an abnormal user; and deleting the user data of the first user from the first ranking list.
6. The method for updating the score ranking list in real time as recited in claim 4, wherein the updating the first ranking list according to the updated user data of the first user, to obtain a final ranking list, specifically comprises:
after receiving the update message of the latest delay event, acquiring updated user data of the first user, modifying the ranking list data of the first ranking list according to the integral data and the integral time of the first user, and ranking the ranking list data through bit operation to acquire a final ranking list.
7. The method for updating the score ranking list in real time as claimed in claim 1, wherein the iteratively detecting whether the first user has a newly triggered score update event within a first preset time after the current score time according to the current score time, further comprises:
and if the fact that the first user does not generate a new integral updating event in a first preset time after the current integral time is detected, the first ranking list is used as a final ranking list.
8. An apparatus for updating an integrated leaderboard in real time, comprising: an updating module and a correcting module;
the updating module is used for receiving an integral updating event triggered by a first user, calculating consumption integral of the integral updating event in a multithreading mode, updating user data and ranking list data of the first user according to the consumption integral, and generating a first ranking list; the point updating event is triggered and generated according to the fact that the first user operates at a client to enable the point to change; the user data includes integral data and an integral time; the ranking list data comprises integral data and ranking data of all users;
The correction module is used for iteratively detecting whether a new triggered integral updating event exists in a first preset time after the current integral time according to the current integral time, and updating user data of the first user according to the new triggered integral updating event when the new triggered integral updating event exists each time until the fact that the new triggered integral updating event does not exist in the first preset time after the current integral time is detected;
and updating the first ranking list according to the updated user data of the first user to obtain a final ranking list, so as to display the final ranking list on the client of the first user.
9. The apparatus for updating a score ranking list in real time as claimed in claim 8, wherein the updating module comprises a user data updating unit and a ranking list data updating unit;
the user data updating unit is used for updating the user data of the first user once every time a consumption point is calculated;
the ranking list data updating unit is used for judging the type of the first user according to an integral updating event every time a consumption integral is calculated;
If the type of the first user is old, ranking the initial ranking list data through bit operation to generate a first ranking list;
if the type of the first user is a new user, adding the ranking list data of the new user into the initial ranking list data in a Zadd mode to generate a first ranking list;
wherein the user data is stored in Redis in a Hash structure; one user corresponds to user data of one Hash structure; the leaderboard data is stored in a set structure in Redis.
10. The apparatus for updating a score ranking list in real time as claimed in claim 8, wherein the correction module comprises: the device comprises a delay event adding unit, a delay event updating unit and a ranking list correcting unit;
the delay event adding unit is used for adding the delay event of the first user in a delay queue of the Redis according to the current integration time of the first user; the delay event delays sending an update message for a first preset time after the current integration time; a user corresponds to a delay event, and the delay event is identified by the id of the user;
the delay event updating unit is used for updating the integral data and the integral time in the user data if detecting that a newly triggered integral updating event exists in a first preset time after the current integral time of the first user; updating the delay event of the first user according to the updated integration time, so that the delay event delays for a first preset time to send an update message after the updated integration time;
Until the first user does not generate a new integral update event in a first preset time after the latest integral time, receiving an update message sent by the first user in a first preset time after the latest delay event of the first user is delayed after the latest integral time;
the ranking list correction unit is used for acquiring updated user data of the first user after receiving the update message of the latest delay event, modifying ranking list data of the first ranking list according to the integral data and the integral time of the first user, and ranking the ranking list data through bit operation to acquire a final ranking list; if the interval between the latest integration time and the initial integration time of the first user is detected to be larger than the second preset time, judging that the first user is an abnormal user; and deleting the user data of the first user from the first ranking list.
CN202211462692.2A 2022-11-22 2022-11-22 Method, device and storage medium for updating integrated ranking list in real time Pending CN116048834A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211462692.2A CN116048834A (en) 2022-11-22 2022-11-22 Method, device and storage medium for updating integrated ranking list in real time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211462692.2A CN116048834A (en) 2022-11-22 2022-11-22 Method, device and storage medium for updating integrated ranking list in real time

Publications (1)

Publication Number Publication Date
CN116048834A true CN116048834A (en) 2023-05-02

Family

ID=86122536

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211462692.2A Pending CN116048834A (en) 2022-11-22 2022-11-22 Method, device and storage medium for updating integrated ranking list in real time

Country Status (1)

Country Link
CN (1) CN116048834A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117270751A (en) * 2023-10-10 2023-12-22 书行科技(北京)有限公司 List interaction method, device, computer equipment and computer readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117270751A (en) * 2023-10-10 2023-12-22 书行科技(北京)有限公司 List interaction method, device, computer equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
US8255920B2 (en) Time management control method for computer system, and computer system
CN116048834A (en) Method, device and storage medium for updating integrated ranking list in real time
US11915054B2 (en) Scheduling jobs on interruptible cloud computing instances
CN108701026A (en) Method and apparatus for the managing process under memory constraints
CN109634822B (en) Function time consumption statistical method and device, storage medium and terminal equipment
JP5638579B2 (en) Evaluation value calculation device, evaluation value calculation method, and program
JP2021518957A (en) Clearing / verification method, equipment and computer equipment
CN112669091B (en) Data processing method, device and storage medium
CN113590007B (en) Method and device for generating progress bar, computer equipment and storage medium
CN113590017B (en) Method, electronic device and computer program product for processing data
CN110784478B (en) Method, device, equipment and computer readable storage medium for adjusting timeout duration
CN110322350B (en) Method, device, equipment and storage medium for cutting hollow block in consensus network
CN111078473A (en) Test item copying method and device
US10955872B2 (en) System and method to retain baseboard management controller real-time clock time during BMC reboot
CN108322542B (en) Data updating method, system, device and computer readable storage medium
US20070198869A1 (en) Timer apparatus, timer processing method, and electronic apparatus
CN109871226B (en) Configuration method, device and medium of downloader and electronic equipment
CN107832859B (en) Game reservation list generation method and device and server
CN112445390B (en) Submenu selection method and device and terminal equipment
JP2014167744A (en) Machine learning apparatus, machine learning method and program
CN110381377B (en) Detection method and device for information playing, electronic equipment and storage medium
CN115098150A (en) Gray scale publishing method, device and system, electronic equipment and storage medium
JP2015015056A (en) Evaluation value calculation apparatus, evaluation value calculation method, and program
JP6274684B2 (en) Allocation determination apparatus, control method, and program
CN117520299A (en) Data processing method, device, equipment and medium during migration of financial system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination