CN113590642A - Data updating method and device, electronic equipment and medium - Google Patents

Data updating method and device, electronic equipment and medium Download PDF

Info

Publication number
CN113590642A
CN113590642A CN202110916289.1A CN202110916289A CN113590642A CN 113590642 A CN113590642 A CN 113590642A CN 202110916289 A CN202110916289 A CN 202110916289A CN 113590642 A CN113590642 A CN 113590642A
Authority
CN
China
Prior art keywords
data
request
updating
target
account
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
CN202110916289.1A
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.)
Weikun Shanghai Technology Service Co Ltd
Original Assignee
Weikun Shanghai Technology Service 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 Weikun Shanghai Technology Service Co Ltd filed Critical Weikun Shanghai Technology Service Co Ltd
Priority to CN202110916289.1A priority Critical patent/CN113590642A/en
Publication of CN113590642A publication Critical patent/CN113590642A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification

Abstract

The embodiment of the application discloses a data updating method, a data updating device, electronic equipment and a storage medium, wherein the method comprises the following steps: firstly, a data updating request of a target account is obtained, the data updating request carries a target account identifier of the target account, then whether the target account is a hot account is judged according to the target account identifier and a target database, if the target account is the hot account, first data of the target account in the target database is updated according to the data updating request, the numerical value of the updated first data is larger than or equal to 0 and is not equal to the numerical value of the first data before updating, and finally, second data of the target account is updated according to the first data. By the method and the device, the second data can not be updated concurrently when a plurality of data updating requests of the second data which are not updated exist, the error rate of updating the second data is reduced, and the safety of the account is improved.

Description

Data updating method and device, electronic equipment and medium
Technical Field
The present application relates to the field of information technology, and in particular, to a data updating method, apparatus, electronic device, and medium.
Background
The hot account data updating is a performance bottleneck, in the processing of an accounting database of a bank or a third-party payment system, data is transferred from an account, or data is transferred into an account, the account receives an accounting request, and an accounting processing process is provided. The accounting processing process mainly comprises two parts, namely recording accounting vouchers and updating the balance of an account.
In the prior art, in order to ensure that the accuracy of data is not affected by other requests, when accounting processing is performed, resources of an account are locked first, and after the accounting processing is completed, the lock is automatically released. With the increase of the accounting processing traffic, an account in the accounting database often generates multiple concurrent operations instantly, but only one of all corresponding concurrent threads can hold a resource lock of the current account, and other threads need to wait for the lock to be released and then perform accounting processing one by one, so that the account is frequently locked and unlocked, the account becomes a hotspot of the accounting database, a performance bottleneck point is generated, and the performance of the accounting database is seriously affected.
Disclosure of Invention
The embodiment of the application provides a data updating method, a device, an electronic device and a medium, and aims to maintain a hotspot account and first data of the hotspot account in a special database, determine to acquire a hotspot account data updating request, update the first data of the hotspot account, record the data updating request, process the data updating request based on the special database without locking, quickly judge whether the data updating request can be processed based on the first data, and record the data updating request under the condition that the first data is updated successfully, so that when a plurality of data updating requests without updating second data exist, the second data cannot be updated concurrently, the error rate of updating the second data is reduced, and the safety of the account is improved.
In a first aspect, an embodiment of the present application provides a data updating method, including:
acquiring a data updating request of a target account, wherein the data updating request carries a target account identifier of the target account;
judging whether the target account is a hotspot account or not according to the target account identifier and a target database, wherein the target database is used for recording hotspot accounts and first data of the hotspot accounts, the first data is n times of the second data, n is larger than 0, and the target database comprises account identifiers of the hotspot accounts;
if the target account is a hotspot account, updating first data of the target account in the target database according to the data updating request, wherein the numerical value of the updated first data is greater than or equal to 0 and is not equal to the numerical value of the first data before updating;
and updating second data of the target account according to the first data.
In one possible example, the updating the first data of the target account in the target database according to the data update request includes:
acquiring a request serial number, a source system, a request type and a service identifier of the data updating request;
generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier;
judging whether the target index is an index appearing for the first time;
and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
In one possible example, the obtaining of the request serial number, the source system, the request type, and the service identifier of the data update request includes:
and acquiring the request serial number, the source system, the request type and the service identifier carried by the data updating request.
In one possible example, the method further comprises:
if the target index is not the index appearing for the first time, ending the current process;
and generating first information according to the data updating request, and sending the first information to user equipment of a target user, wherein the first information is used for indicating that the target index is abnormal.
In one possible example, the updating the first data of the target account in the target database according to the data update request includes:
obtaining a numerical value of the first data before updating of the target account;
judging whether the data updating request is a numerical value reduction request or not;
if the request type is a value reduction request, judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000021
If the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000031
Obtaining the updated numerical value of the first data according to the numerical value of the first data before updating and the numerical value corresponding to the data updating request, wherein the updated numerical value of the first data is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure BDA0003204718170000032
A difference of (d);
if the request type is a value increasing request, obtaining the updated value of the first data according to the value of the first data before updating and the value corresponding to the data updating request, wherein the updated value of the first data is equal to the value of the first data before updating and the value corresponding to the data updating request
Figure BDA0003204718170000033
The sum of (a) and (b).
In one possible example, the determining whether the value of the first data before updating is greater than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000034
Thereafter, the method further comprises:
if the value of the first data before updating is smaller than the value corresponding to the data updating request
Figure BDA0003204718170000035
Ending the current process;
and generating second information according to the data updating request, and sending the second information to user equipment of a target user, wherein the second information is used for indicating that the processing of the data updating request fails.
In one possible example, the updating the second data of the target account according to the first data includes:
under the condition that the value of the first data changes, adding the data updating request to a request queue, wherein the request queue is used for indicating data updating requests of second data which are not updated and are sequentially arranged in the order from front to back according to the processing time;
and updating the numerical value of the second data of the second account according to the data updating requests in the request queue in sequence.
In a second aspect, an embodiment of the present application provides a data updating device, including an obtaining unit, configured to obtain a data updating request of a target account, where the data updating request carries a target account identifier of the target account;
a determining unit, configured to determine whether the target account is a hotspot account according to the target account identifier and a target database, where the target database is used to record a hotspot account and first data of the hotspot account, where the first data is n times of the second data, n is greater than 0, and the target database includes an account identifier of the hotspot account;
a first data updating unit, configured to update, according to the data updating request, first data of the target account in the target database if the target account is a hotspot account, where a numerical value of the updated first data is greater than or equal to 0 and is not equal to a numerical value of the first data before updating;
and the second data updating unit is used for updating second data of the target account according to the first data.
In one possible example, in the aspect of updating the first data of the target account in the target database according to the data update request, the first data updating unit is specifically configured to:
acquiring a request serial number, a source system, a request type and a service identifier of the data updating request;
generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier;
judging whether the target index is an index appearing for the first time;
and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
In a possible example, in terms of the request serial number, the source system, the request type, and the service identifier of the data update request, the first data update unit is specifically configured to:
and acquiring the request serial number, the source system, the request type and the service identifier carried by the data updating request.
In one possible example, the apparatus further comprises a prompting unit configured to:
if the target index is not the index appearing for the first time, ending the current process;
and generating first information according to the data updating request, and sending the first information to user equipment of a target user, wherein the first information is used for indicating that the target index is abnormal.
In one possible example, in the aspect of updating the first data of the target account in the target database according to the data update request, the first data updating unit is specifically configured to:
obtaining a numerical value of the first data before updating of the target account;
judging whether the data updating request is a numerical value reduction request or not;
if the request type is a numerical valueReducing the request, and judging whether the numerical value of the first data before updating is larger than or equal to the numerical value corresponding to the data updating request
Figure BDA0003204718170000041
If the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000042
Obtaining the updated numerical value of the first data according to the numerical value of the first data before updating and the numerical value corresponding to the data updating request, wherein the updated numerical value of the first data is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure BDA0003204718170000043
A difference of (d);
if the request type is a value increasing request, obtaining the updated value of the first data according to the value of the first data before updating and the value corresponding to the data updating request, wherein the updated value of the first data is equal to the value of the first data before updating and the value corresponding to the data updating request
Figure BDA0003204718170000044
The sum of (a) and (b).
In one possible example, the prompting unit is further configured to: judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000045
Then, if the value of the first data before updating is smaller than the value corresponding to the data updating request
Figure BDA0003204718170000051
Ending the current process;
and generating second information according to the data updating request, and sending the second information to user equipment of a target user, wherein the second information is used for indicating that the processing of the data updating request fails.
In one possible example, in terms of the updating the second data of the target account according to the first data, the second data updating unit is specifically configured to:
under the condition that the value of the first data changes, adding the data updating request to a request queue, wherein the request queue is used for indicating data updating requests of second data which are not updated and are sequentially arranged in the order from front to back according to the processing time;
and updating the numerical value of the second data of the target account according to the data updating requests in the request queue in sequence.
In a third aspect, embodiments of the present application provide an electronic device comprising a processor, a memory, a communication interface, and one or more programs stored in the memory and configured to be executed by the processor, the one or more programs including instructions for performing the steps of the method as set forth in the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium storing a computer program for electronic data exchange, wherein the computer program causes a computer to execute the steps in the method as shown in the first aspect.
It can be seen that, in the embodiment of the application, first, a data update request of a target account is obtained, where the data update request carries a target account identifier of the target account, then, according to the target account identifier and a target database, it is determined whether the target account is a hotspot account, the target database is used to record a hotspot account and first data of the hotspot account, where the first data is used to reflect second data of the hotspot account, and the target database includes an account identifier of the hotspot account, if the target account is a hotspot account, according to the data update request, the first data of the target account in the target database is updated, where a numerical value of the updated first data is greater than or equal to 0 and not equal to a numerical value of the first data before updating, and finally, a numerical value of the second data of the target account is updated according to the first data. It can be seen that, according to the application, the hotspot account and the first data of the hotspot account are maintained in a special database, after the hotspot account data updating request is determined to be obtained, the first data of the hotspot account are updated, the data updating request is recorded, and when the data updating request is processed based on the special database without locking, whether the data updating request can be processed based on the first data can be rapidly identified, and under the condition that the first data is updated successfully, the data updating request is recorded, so that when a plurality of data updating requests without updating the second data exist, the second data cannot be updated concurrently, the error rate of updating the second data is reduced, and the safety of the account is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a data updating method provided in an embodiment of the present application;
FIG. 2 is a schematic structural diagram of a data updating apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an electronic device according to another embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, apparatus, and storage medium, product, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may alternatively include other steps or elements not expressly listed or inherent to such process, method, product, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the prior art, in order to ensure that the accuracy of data is not affected by other requests, when accounting processing is performed, resources of an account are locked first, and after the accounting processing is completed, the lock is automatically released. With the increase of the accounting processing traffic, an account in the accounting database often generates multiple concurrent operations instantly, but only one of all corresponding concurrent threads can hold a resource lock of the current account, and other threads need to wait for the lock to be released and then perform accounting processing one by one, so that the account is frequently locked and unlocked, the account becomes a hotspot of the accounting database, a performance bottleneck point is generated, and the performance of the accounting database is seriously affected.
Based on the above problems, embodiments of the present invention provide a data updating method, which is described in detail below.
A data updating method in the embodiment of the present application is described below with reference to fig. 1, where fig. 1 is a schematic flow chart of the data updating method provided in the embodiment of the present application, and the method specifically includes the following steps S101 to S104.
S101, acquiring a data updating request of the target account.
And the data updating request carries the target account identification of the target account.
The data update request may be a value increase request and a value decrease request, the value increase request is a request for sending money to the target account, and the value decrease request is a request for sending money from the target account to another account. The account identifier refers to a unique identifier of an account, one account corresponds to one unique identifier, different accounts correspond to different unique identifiers, and the unique identifier can be an account number.
As can be seen, in this example, the account identifier is carried in the data update request in advance, so that the account of the data update request is determined based on the account identifier.
And S102, judging whether the target account is a hot spot account or not according to the target account identifier and the target database.
The target database is used for recording a hotspot account and first data of the hotspot account, the first data is used for reflecting second data of the hotspot account, the first data is n times of the second data of the hotspot account, n is greater than 0, specifically, n may be 0.5, 1, 5, and the like, without specific limitation, and the target database includes an account identifier of the hotspot account.
The target database is created by a service provider, stored in electronic equipment provided by the service provider, and used for maintaining a hotspot account and first data of the hotspot account. If the account created by the user is the hotspot account, the server records the account identification of the hotspot account and the first data in the target database. If the account created by the user is not the hotspot account, the server does not record the account identifier of the hotspot account and the first data in the target database.
Specifically, the implementation manner of determining whether the target account is a hotspot account according to the target account identifier and the target database may be: comparing the target account identification with the account identification in the target database one by one; if the target account identification exists in the target database, determining that the target account is the hotspot account; if the target account identification does not exist in the target database, determining that the target account is not the hotspot account.
As can be seen, in this example, only the account identifier of the hot account is stored in the target database in advance, the target account identifier is compared with the account identifiers stored in the target database one by one, if the target database has the target account identifier, it is determined that the target account is the hot account, and if the target database has the target account identifier, it is determined that the target account is not the hot account, so that the intelligence of determining the hot account is improved, and the efficiency of updating the account data is further improved.
The target database may be in the form of a table, or may be in the form of an account set, and is not particularly limited.
Taking three created accounts as an example, if the three created accounts include account a, the account a corresponds to account number 1, and the first data is 200; account B, corresponding to account number 2, with first data of 5000; account C, corresponding to account number 3, and the first data is 9000.
Illustratively, the target database is in the form of a table, and specifically, the aforementioned three accounts created may be recorded as:
account Account number First data (element)
A 1 200.00
B 2 5000.00
C 3 9000.00
For example, the target database is in the form of an account set, and then the target database may be presented in the following { x, y, z }, where x refers to an account, y refers to an account number, z refers to first data, and the unit is an element, specifically, the aforementioned three created accounts may be recorded as: { account a, account 1, 200.00}, { account B, account 2, 5000.00}, and { account C, account 3, 9000.00 }.
It will be appreciated that the value of the second data may be equal to the value of the first data.
In this example, by maintaining the target database recording the account identifier of the hot account, it can be determined whether the account corresponding to the data update request carrying the target account identifier is the hot account, and the target database is managed in a unified manner.
S103, if the target account is the hotspot account, updating the first data of the target account in the target database according to the data updating request.
And the numerical value of the first data after updating is greater than or equal to 0 and is not equal to the numerical value of the first data before updating.
In a specific implementation, when the data update request is a value increase request, the updated value of the first data is the value of the first data before update and the value of the amount of money of the data update request
Figure BDA0003204718170000091
And (4) summing. When the data update request is that the numerical value of the first data after update is the numerical value of the first data before update and the numerical value of the amount of money of the data update request
Figure BDA0003204718170000092
The difference, and only if the value of the first data before update is greater than or equal to the value of the amount of money requested for data update
Figure BDA0003204718170000093
The first data can be updated successfully.
And S104, updating second data of the target account according to the first data.
In a specific implementation, when the data update request is a value increase request, the updated value of the second data is the value of the second data before update and the value of the amount of money of the data update request
Figure BDA0003204718170000094
And (4) summing. When the data update request is a value decrease request, the updated value of the second data is the value of the second data before update and the value of the amount of money requested by the data update
Figure BDA0003204718170000095
Specifically, the second data of the target account can be updated according to the data update request only after the first data of the target account is successfully updated according to the data update request.
It can be seen that, in the embodiment of the application, first, a data update request of a target account is obtained, where the data update request carries a target account identifier of the target account, then, according to the target account identifier and a target database, it is determined whether the target account is a hotspot account, the target database is used to record a hotspot account and first data of the hotspot account, where the first data is used to reflect second data of the hotspot account, and the target database includes an account identifier of the hotspot account, if the target account is a hotspot account, according to the data update request, the first data of the target account in the target database is updated, where a numerical value of the updated first data is greater than or equal to 0 and not equal to a numerical value of the first data before updating, and finally, a numerical value of the second data of the hotspot account is updated according to the first data. It can be seen that, according to the application, the hotspot account and the first data of the hotspot account are maintained in a special database, after the hotspot account data updating request is determined to be obtained, the first data of the hotspot account are updated, the data updating request is recorded, and when the data updating request is processed based on the special database without locking, whether the data updating request can be processed based on the first data can be rapidly identified, and under the condition that the first data is updated successfully, the data updating request is recorded, so that when a plurality of data updating requests without updating the second data exist, the second data cannot be updated concurrently, the error rate of updating the second data is reduced, and the safety of the account is improved.
As a possible implementation manner, the updating the first data of the target account in the target database according to the data update request includes: acquiring a request serial number, a source system, a request type and a service identifier of the data updating request; generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier; judging whether the target index is an index appearing for the first time; and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
Wherein the source system is a system generating the data update request.
Specifically, the implementation manner of generating the target index of the data update request according to the request serial number, the source system, the request type, and the service identifier may be: generating a first sub-code corresponding to the request serial number according to the request serial number and a first mapping relation, wherein the first mapping relation comprises the corresponding relation between the request serial number and the first sub-code; generating a second subcode corresponding to the source system according to the source system and a second mapping relation, wherein the second mapping relation comprises the corresponding relation between the source system and the second subcode; generating a third subcode corresponding to the request type according to the request type and a third mapping relation, wherein the third mapping relation comprises the corresponding relation between the request type and the third subcode; generating a fourth sub-code corresponding to the service identifier according to the service identifier and a fourth mapping relation, wherein the third mapping relation comprises a corresponding relation between the service identifier and the fourth sub-code; generating the target index according to the first subcode, the second subcode, the third subcode, and the fourth subcode.
Wherein, one request serial number corresponds to one first subcode, and different request serial numbers correspond to different first subcodes; one source system corresponds to one second subcode, and different source systems correspond to different second subcodes; one request type generates a third subcode, and different request types generate different third subcodes; one service identifier generates a fourth subcode, and different service identifiers generate different fourth subcodes.
Further, the implementation manner of generating the target index according to the first sub-code, the second sub-code, the third sub-code, and the fourth sub-code may be: and sequencing the first subcode, the second subcode, the third subcode and the fourth subcode according to a preset arrangement sequence to generate the target index. The preset arrangement sequence may be, from front to back, the first subcode, the second subcode, the third subcode, and the fourth subcode in sequence; the preset arrangement sequence may be the fourth subcode, the third subcode, the second subcode, and the first subcode from front to back, and the preset arrangement sequence is not specifically limited.
As a possible implementation manner, the obtaining of the request serial number, the source system, the request type, and the service identifier of the data update request includes: and acquiring the request serial number, the source system, the request type and the service identifier carried by the data updating request.
It can be seen that in this example, the first data of the target account in the target database is updated based on the data update request only if the target index is the first-appearing index. That is, the first data of the target account in the target database is updated based on the data update request when the data update request is not a repeated data update request.
As a possible implementation, the method further includes: if the target index is not the index appearing for the first time, ending the current process; and generating first information according to the data updating request, and sending the first information to user equipment of a target user, wherein the first information is used for indicating that the target index is abnormal.
The target user can be at least one of a requesting user, a user corresponding to the target account and a data update request supervisor set by a service provider. The target user may also be another user, and is not particularly limited.
The first information includes, but is not limited to, at least one of a request number, a request serial number, a source system, a request type, a service identifier, index duplication information, and request duplication information of the data update request. In a specific implementation, one data update request corresponds to one request number, and different data update requests correspond to different request numbers, the index repetition information may be that the target index is a repetition index, and the request repetition information may be that the data update request is a repetition data update request.
For example, the first information may be "the index of the currently processed data update request is a duplicate index, and the currently processed data update request is a duplicate index," which is not particularly limited.
As can be seen, in this example, when the target index is not the index appearing for the first time, the first data of the target account in the target database is not updated based on the data update request, and the prompt information indicating that the index of the data update request is abnormal is output, so that the first data of the target account is prevented from being affected by the data update request submitted repeatedly, and further, the second data of the target account is prevented from being affected by the data update request submitted repeatedly.
As a possible implementation manner, the updating the first data of the target account in the target database according to the data update request includes: obtaining a numerical value of the first data before updating of the target account; judging whether the data updating request is a numerical value reduction request or not; if the request type is a value reduction request, judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000111
If the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000112
Obtaining the updated numerical value of the first data according to the numerical value of the first data before updating and the numerical value corresponding to the data updating request, wherein the updated numerical value of the first data is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure BDA0003204718170000121
A difference of (d); if the request type is a value increasing request, obtaining the updated value of the first data according to the value of the first data before updating and the value corresponding to the data updating request, wherein the updated value of the first data is equal to the value of the first data before updating and the value corresponding to the data updating requestIs/are as follows
Figure BDA0003204718170000122
The sum of (a) and (b).
For example, when n is 1, that is, when the value of the first data is equal to the value of the second data, if the value of the first data before the update of the target account is 500, the data update request is a value decrease request, and the value of the amount of money of the value decrease request is 201, it is determined that the value 500 of the first data before the update is greater than the value 201 of the amount of money of the value decrease request, and then the value 500 of the first data is updated to 299. If the value of the first data before the update of the target account is 500, the data update request is a value increase request, and the value of the amount of the value increase request is 201, then the value of the first data is updated to be 799.
For example, when n is 2, if the value of the first data before updating of the target account is 500, the data updating request is a value decreasing request, and the value of the amount of money of the value decreasing request is 201, it is determined that the value of the first data before updating 500 is greater than the value of the amount of money of the value decreasing request
Figure BDA0003204718170000123
I.e., 100.5, the value 500 of the first data is updated to 399.5. If the value of the first data before the update of the target account is 500, the data update request is a value increase request, and the value of the amount of the value increase request is 201, the value 500 of the first data is updated to 600.5.
For example, when n is
Figure BDA0003204718170000124
If the value of the first data before updating of the target account is 500, the data updating request is a value reduction request, and the value of the amount of money of the value reduction request is 201, then it is determined that the value of the first data before updating 500 is greater than the value of the amount of money of the value reduction request
Figure BDA0003204718170000125
I.e., 402, the value 500 of the first data is updated to 98. If the value of the first data before the update of the target account is 500, the data update request is a value increase request, and the value of the amount of the value increase request is 201, then the value 500 of the first data is updated to 902.
It can be seen that in this example, when the data update request is a value increase request, the value of the first data can be directly updated to be the sum of the value of the first data before update and the value corresponding to the data update request, and when the data update request is a value decrease request, it is required to determine that the value of the first data before update is greater than or equal to the value corresponding to the data update request, and update the value of the first data to be the sum of the value of the first data before update and the value corresponding to the data update request, so that in a case that updating the first data is successful, the data update request is recorded, so as to ensure that when there are multiple data update requests without updating the second data, the second data cannot be updated concurrently, reduce an error rate of data update, and improve security of the account.
As a possible implementation manner, the determining whether the value of the first data before updating is greater than or equal to the value corresponding to the data updating request is performed
Figure BDA0003204718170000126
Thereafter, the method further comprises: if the value of the first data before updating is smaller than the value corresponding to the data updating request
Figure BDA0003204718170000127
Ending the current process; and generating second information according to the data updating request, and sending the second information to user equipment of a target user, wherein the second information is used for indicating that the processing of the data updating request fails.
Wherein the second information includes, but is not limited to, at least one of a request number, a request serial number, a source system, a request type, a service identifier, and processing failure information of the data update request. The processing failure information includes a result of the processing failure of the data update request and a reason.
For example, the second information may be "currently processed data update request processing fails, failure reason: the account balance of the target account is insufficient ", and the second information is not particularly limited.
As can be seen, in this example, when the data update request is a value reduction request, it is necessary to determine that the value of the first data before update is smaller than the value corresponding to the data update request
Figure BDA0003204718170000131
And ending the current process, outputting prompt information indicating that the data updating request fails to be processed, and avoiding updating the second data of the target account when the numerical value of the second data is smaller than the numerical value corresponding to the data updating request.
As a possible implementation manner, the updating the second data of the target account according to the first data includes: under the condition that the value of the first data changes, adding the data updating request to a request queue, wherein the request queue is used for indicating data updating requests of second data which are not updated and are sequentially arranged in the order from front to back according to the processing time; and updating the numerical value of the second data of the target account according to the data updating requests in the request queue in sequence.
Wherein the change in the value of the first data includes an increase in the value of the first data and a decrease in the value of the first data.
Wherein, according to the data update requests in the request queue in turn, the updating of the value of the second data of the target account may be implemented by performing the following operations for each data update request in the request queue: obtaining a numerical value of the second data of the target account before updating; and obtaining a value of the updated second data according to the value of the second data before updating and a value corresponding to a target data updating request in the currently processed request queue, wherein when the target data updating request in the currently processed request queue is a value decreasing request, the updated value of the second data is equal to a difference between the value of the second data before updating and the value corresponding to the target data updating request, and when the target data updating request in the currently processed request queue is a value increasing request, the updated value of the second data is equal to a sum of the value of the second data before updating and the value corresponding to the target data updating request.
Illustratively, the value of the second data before the update of the target account is 500, the value corresponding to the target data update request is 201, when the target data update request is a value decrease request, the value 500 for updating the second data is 299, and when the target data update request is a value increase request, the value 500 for updating the second data is 701.
It should be noted that, after updating the second data based on the data update request in the request queue, the data update request that has completed the second data update is immediately moved out of the request queue, thereby ensuring that the data update request in the request queue is a data update request that does not update the second data.
It will be appreciated that qualified data update requests (not duplicative and not numeric for the requested amount) are filtered out by the first data of the hotspot account
Figure BDA0003204718170000141
The data update request is larger than the first data before update), and then the second data of the hotspot account is updated based on the qualified delivery request.
In the case of an integrated unit, referring to fig. 2, fig. 2 provides a block diagram of a functional unit of a data update apparatus. The data updating apparatus 200 is applied to an electronic device, and specifically includes:
an obtaining unit 210, configured to obtain a data update request of a target account, where the data update request carries a target account identifier of the target account;
a determining unit 220, configured to determine whether the target account is a hotspot account according to the target account identifier and a target database, where the target database is used to record a hotspot account and first data of the hotspot account, where the first data is n times of the second data, n is greater than 0, and the target database includes an account identifier of the hotspot account;
a first data updating unit 230, configured to update, according to the data updating request, first data of the target account in the target database if the target account is a hotspot account, where a numerical value of the updated first data is greater than or equal to 0 and is not equal to a numerical value of the first data before updating;
a second data updating unit 240, configured to update second data of the target account according to the first data.
The data update apparatus 200 may further include a storage unit 250 for storing program codes and data of the terminal. The storage unit 250 may be a memory. When the storage unit 250 is a memory, the data updating apparatus 200 according to the embodiment of the present application may be an electronic device shown in fig. 3.
It should be noted that specific implementation of each operation may be described in detail in the method embodiment shown in fig. 1, and is not described in detail here.
It can be seen that, in the embodiment of the application, first, a data update request of a target account is obtained, where the data update request carries a target account identifier of the target account, then, according to the target account identifier and a target database, it is determined whether the target account is a hotspot account, the target database is used to record a hotspot account and first data of the hotspot account, where the first data is used to reflect second data of the hotspot account, and the target database includes an account identifier of the hotspot account, if the target account is a hotspot account, according to the data update request, the first data of the target account in the target database is updated, where a numerical value of the updated first data is greater than or equal to 0 and not equal to a numerical value of the first data before updating, and finally, a numerical value of the second data of the target account is updated according to the first data. It can be seen that, according to the application, the hotspot account and the first data of the hotspot account are maintained in a special database, after the hotspot account data updating request is determined to be obtained, the first data of the hotspot account are updated, the data updating request is recorded, and when the data updating request is processed based on the special database without locking, whether the data updating request can be processed based on the first data can be rapidly identified, and under the condition that the first data is updated successfully, the data updating request is recorded, so that when a plurality of data updating requests without updating the second data exist, the second data cannot be updated concurrently, the error rate of updating the second data is reduced, and the safety of the account is improved.
In a possible example, in the aspect of updating the first data of the target account in the target database according to the data update request, the first data updating unit 230 is specifically configured to:
acquiring a request serial number, a source system, a request type and a service identifier of the data updating request;
generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier;
judging whether the target index is an index appearing for the first time;
and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
In a possible example, in terms of the request serial number, the source system, the request type, and the service identifier of the data update request, the first data update unit 230 is specifically configured to:
and acquiring the request serial number, the source system, the request type and the service identifier carried by the data updating request.
In one possible example, the apparatus further comprises a prompting unit 260, the prompting unit 260 being configured to:
if the target index is not the index appearing for the first time, ending the current process;
and generating first information according to the data updating request, and sending the first information to user equipment of a target user, wherein the first information is used for indicating that the target index is abnormal.
In a possible example, in the aspect of updating the first data of the target account in the target database according to the data update request, the first data updating unit 230 is specifically configured to:
obtaining a numerical value of the first data before updating of the target account;
judging whether the data updating request is a numerical value reduction request or not;
if the request type is a value reduction request, judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000161
If the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000162
Obtaining the updated numerical value of the first data according to the numerical value of the first data before updating and the numerical value corresponding to the data updating request, wherein the updated numerical value of the first data is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure BDA0003204718170000163
A difference of (d);
if the request type is a value increasing request, obtaining an updated value according to the value of the first data before updating and the value corresponding to the data updating requestThe numerical value of the first data after updating is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure BDA0003204718170000164
The sum of (a) and (b).
In one possible example, the prompting unit 260 is further configured to: judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000165
Then, if the value of the first data before updating is smaller than the value corresponding to the data updating request
Figure BDA0003204718170000166
Ending the current process;
and generating second information according to the data updating request, and sending the second information to user equipment of a target user, wherein the second information is used for indicating that the processing of the data updating request fails.
In one possible example, in terms of the updating the second data of the target account according to the first data, the second data updating unit 240 is specifically configured to:
under the condition that the value of the first data changes, adding the data updating request to a request queue, wherein the request queue is used for indicating data updating requests of second data which are not updated and are sequentially arranged in the order from front to back according to the processing time;
and updating the numerical value of the second data of the target account according to the data updating requests in the request queue in sequence.
Referring to fig. 3, which is a schematic structural diagram of an electronic device provided in an embodiment of the present application, an electronic device 300 in the embodiment shown in fig. 3 may include: a processing module 310, a memory 320, a communication interface 330, and one or more programs 321, the one or more programs 321 being stored in the memory 320 and configured to be executed by the processing module 310, the one or more programs 321 comprising instructions for performing steps in a method as described below:
acquiring a data updating request of a target account, wherein the data updating request carries a target account identifier of the target account;
judging whether the target account is a hotspot account or not according to the target account identifier and a target database, wherein the target database is used for recording hotspot accounts and first data of the hotspot accounts, the first data is n times of the second data, n is larger than 0, and the target database comprises account identifiers of the hotspot accounts;
if the target account is a hotspot account, updating first data of the target account in the target database according to the data updating request, wherein the numerical value of the updated first data is greater than or equal to 0 and is not equal to the numerical value of the first data before updating;
and updating second data of the target account according to the first data.
The Processing module 310 may be a Central Processing Unit (CPU), and the Processor may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, a discrete hardware component, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It should be noted that specific implementation of each operation may be described in detail in the method embodiment shown in fig. 1, and is not described in detail here.
It can be seen that, in the embodiment of the application, first, a data update request of a target account is obtained, where the data update request carries a target account identifier of the target account, then, according to the target account identifier and a target database, it is determined whether the target account is a hotspot account, the target database is used to record a hotspot account and first data of the hotspot account, where the first data is used to reflect second data of the hotspot account, and the target database includes an account identifier of the hotspot account, if the target account is a hotspot account, according to the data update request, the first data of the target account in the target database is updated, where a numerical value of the updated first data is greater than or equal to 0 and not equal to a numerical value of the first data before updating, and finally, a numerical value of the second data of the target account is updated according to the first data. It can be seen that, according to the application, the hotspot account and the first data of the hotspot account are maintained in a special database, after the hotspot account data updating request is determined to be obtained, the first data of the hotspot account are updated, the data updating request is recorded, and when the data updating request is processed based on the special database without locking, whether the data updating request can be processed based on the first data can be rapidly identified, and under the condition that the first data is updated successfully, the data updating request is recorded, so that when a plurality of data updating requests without updating the second data exist, the second data cannot be updated concurrently, the error rate of updating the second data is reduced, and the safety of the account is improved.
In one possible example, in the aspect of updating the first data of the target account in the target database according to the data update request, the instructions in the one or more programs 321 are specifically configured to perform the following steps:
acquiring a request serial number, a source system, a request type and a service identifier of the data updating request;
generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier;
judging whether the target index is an index appearing for the first time;
and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
In one possible example, in terms of the request serial number, the source system, the request type, and the service identifier of the data update request, the instructions in the one or more programs 321 are specifically configured to perform the following steps:
and acquiring the request serial number, the source system, the request type and the service identifier carried by the data updating request.
In one possible example, the one or more programs 321 further include instructions for performing steps in a method as described below:
if the target index is not the index appearing for the first time, ending the current process;
and generating first information according to the data updating request, and sending the first information to user equipment of a target user, wherein the first information is used for indicating that the target index is abnormal.
In one possible example, in the aspect of updating the first data of the target account in the target database according to the data update request, the instructions in the one or more programs 321 are specifically configured to perform the following steps:
obtaining a numerical value of the first data before updating of the target account;
judging whether the data updating request is a numerical value reduction request or not;
if the request type is a value reduction request, judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000181
If the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure BDA0003204718170000182
Obtaining the updated numerical value of the first data according to the numerical value of the first data before updating and the numerical value corresponding to the data updating request, wherein the updated numerical value of the first data is equal to the numerical value before updatingThe value of the first data and the value corresponding to the data update request
Figure BDA0003204718170000183
A difference of (d);
if the request type is a value increasing request, obtaining the updated value of the first data according to the value of the first data before updating and the value corresponding to the data updating request, wherein the updated value of the first data is equal to the value of the first data before updating and the value corresponding to the data updating request
Figure BDA0003204718170000191
The sum of (a) and (b).
In one possible example, the one or more programs 321 further include instructions for performing steps in a method as described below:
judging whether the numerical value of the first data before updating is larger than or equal to the numerical value corresponding to the data updating request
Figure BDA0003204718170000192
Then, if the value of the first data before updating is smaller than the value corresponding to the data updating request
Figure BDA0003204718170000193
Ending the current process;
and generating second information according to the data updating request, and sending the second information to user equipment of a target user, wherein the second information is used for indicating that the processing of the data updating request fails.
In one possible example, in the aspect of updating the second data of the target account according to the first data, the instructions in the one or more programs 321 are specifically configured to perform the following steps:
under the condition that the value of the first data changes, adding the data updating request to a request queue, wherein the request queue is used for indicating data updating requests of second data which are not updated and are sequentially arranged in the order from front to back according to the processing time;
and updating the numerical value of the second data of the target account according to the data updating requests in the request queue in sequence.
Also provided in embodiments of the present application is a computer-readable storage medium storing a computer program, where the computer program includes program instructions, and the program instructions, when executed by a processor, implement the data updating method shown in the embodiment in fig. 2.
The computer readable storage medium may be an internal storage unit of the electronic device according to any of the foregoing embodiments, for example, a hard disk or a memory of the control device. The computer-readable storage medium may also be an external storage device of the control device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like provided on the control device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the control device. The computer-readable storage medium is used to store the computer program and other programs and data required by the control device. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
By way of example, the computer-readable storage medium described above may be deployed to be executed on one computer device or on multiple computer devices at one site or distributed across multiple sites and interconnected by a communication network, and the multiple computer devices distributed across the multiple sites and interconnected by the communication network may constitute a blockchain network.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for updating data, comprising:
acquiring a data updating request of a target account, wherein the data updating request carries a target account identifier of the target account;
judging whether the target account is a hotspot account or not according to the target account identifier and a target database, wherein the target database is used for recording hotspot accounts and first data of the hotspot accounts, the first data is n times of the second data, n is larger than 0, and the target database comprises account identifiers of the hotspot accounts;
if the target account is a hotspot account, updating first data of the target account in the target database according to the data updating request, wherein the numerical value of the updated first data is greater than or equal to 0 and is not equal to the numerical value of the first data before updating;
and updating second data of the target account according to the first data.
2. The method of claim 1, wherein the updating the first data of the target account in the target database according to the data update request comprises:
acquiring a request serial number, a source system, a request type and a service identifier of the data updating request;
generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier;
judging whether the target index is an index appearing for the first time;
and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
3. The method of claim 2, further comprising:
if the target index is not the index appearing for the first time, ending the current process;
and generating first information according to the data updating request, and sending the first information to user equipment of a target user, wherein the first information is used for indicating that the target index is abnormal.
4. The method of claim 1, wherein the updating the first data of the target account in the target database according to the data update request comprises:
obtaining a numerical value of the first data before updating of the target account;
judging whether the data updating request is a numerical value reduction request or not;
if the request type is a value reduction request, judging whether the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure FDA0003204718160000011
If the value of the first data before updating is larger than or equal to the value corresponding to the data updating request
Figure FDA0003204718160000021
Obtaining the updated numerical value of the first data according to the numerical value of the first data before updating and the numerical value corresponding to the data updating request, wherein the updated numerical value of the first data is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure FDA0003204718160000022
A difference of (d);
if the request type is a value increasing request, obtaining the updated value according to the value of the first data before updating and the value corresponding to the data updating requestThe numerical value of the first data after updating is equal to the numerical value of the first data before updating and the numerical value corresponding to the data updating request
Figure FDA0003204718160000023
The sum of (a) and (b).
5. The method of claim 4, wherein the determining whether the value of the first data before updating is greater than or equal to the value corresponding to the data updating request is performed
Figure FDA0003204718160000024
Thereafter, the method further comprises:
if the value of the first data before updating is smaller than the value corresponding to the data updating request
Figure FDA0003204718160000025
Ending the current process;
and generating second information according to the data updating request, and sending the second information to user equipment of a target user, wherein the second information is used for indicating that the processing of the data updating request fails.
6. The method of claim 1, wherein updating the second data of the target account based on the first data comprises:
under the condition that the value of the first data changes, adding the data updating request to a request queue, wherein the request queue is used for indicating data updating requests of second data which are not updated and are sequentially arranged in the order from front to back according to the processing time;
and updating the numerical value of the second data of the target account according to the data updating requests in the request queue in sequence.
7. An apparatus for updating data, the apparatus comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a data updating request of a target account, and the data updating request carries a target account identifier of the target account;
a determining unit, configured to determine whether the target account is a hotspot account according to the target account identifier and a target database, where the target database is used to record a hotspot account and first data of the hotspot account, where the first data is n times of the second data, n is greater than 0, and the target database includes an account identifier of the hotspot account;
a first data updating unit, configured to update, according to the data updating request, first data of the target account in the target database if the target account is a hotspot account, where a numerical value of the updated first data is greater than or equal to 0 and is not equal to a numerical value of the first data before updating;
and the second data updating unit is used for updating second data of the target account according to the first data.
8. The apparatus according to claim 7, wherein, in the updating the first data of the target account in the target database according to the data update request, the first data updating unit is specifically configured to:
acquiring a request serial number, a source system, a request type and a service identifier of the data updating request;
generating a target index of the data updating request according to the request serial number, the source system, the request type and the service identifier;
judging whether the target index is an index appearing for the first time;
and if the target index is the index appearing for the first time, updating the first data of the target account in the target database according to the data updating request.
9. An electronic device comprising a processor, a memory, a communication interface, and one or more programs, the one or more programs being stored in the memory and configured to be executed by the processor, the one or more programs including instructions for performing the steps in the method of any of claims 1-6.
10. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the steps in the method according to any of claims 1-6.
CN202110916289.1A 2021-08-10 2021-08-10 Data updating method and device, electronic equipment and medium Pending CN113590642A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110916289.1A CN113590642A (en) 2021-08-10 2021-08-10 Data updating method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110916289.1A CN113590642A (en) 2021-08-10 2021-08-10 Data updating method and device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN113590642A true CN113590642A (en) 2021-11-02

Family

ID=78256984

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110916289.1A Pending CN113590642A (en) 2021-08-10 2021-08-10 Data updating method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN113590642A (en)

Similar Documents

Publication Publication Date Title
CN107633016B (en) Data processing method and device and electronic equipment
CN108710681B (en) File acquisition method, device, equipment and storage medium
CN111163182A (en) Block chain-based device registration method and apparatus, electronic device, and storage medium
CN110084600B (en) Processing and verifying method, device, equipment and medium for resolution transaction request
WO2013173238A1 (en) Electronic transaction notification system and method
CN111679968A (en) Interface calling abnormity detection method and device, computer equipment and storage medium
CN112613993A (en) Transaction data processing method and device, computer equipment and storage medium
CN111431908B (en) Access processing method and device, management server and readable storage medium
CN113779545A (en) Data cross-process sharing method, terminal equipment and computer readable storage medium
CN112363997B (en) Data version management method, device and storage medium
CN113468276A (en) Trusted data acquisition method and device of on-chain prediction machine and electronic equipment
CN112685077A (en) Data modification method, system, computer device and computer readable storage medium
CN107844520A (en) Electronic installation, vehicle data introduction method and storage medium
CN116993523A (en) Configurable account checking method, device, equipment and storage medium
CN111340635A (en) Data checking method, equipment, server and readable storage medium
CN115952220A (en) Bill processing method and device based on block chain, electronic equipment and medium
CN113590642A (en) Data updating method and device, electronic equipment and medium
CN114742630A (en) Method for processing business documents and corresponding system, equipment and medium
CN113592645A (en) Data verification method and device
CN111901299A (en) Application authentication method and device, electronic equipment and storage medium
CN114567573B (en) Abnormal data positioning method, device, server and storage medium
CN114997991B (en) Method, device, computer equipment and storage medium for intercepting withdrawal risk
CN112000676B (en) Vehicle information updating method, device, equipment and storage medium
CN109658100B (en) System and method for determining downlink digital assets
CN114168582A (en) Data verification method, system, device and medium based on data quality rule

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