CN111143388A - Resource processing method, device, equipment and storage medium - Google Patents

Resource processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN111143388A
CN111143388A CN201911376842.6A CN201911376842A CN111143388A CN 111143388 A CN111143388 A CN 111143388A CN 201911376842 A CN201911376842 A CN 201911376842A CN 111143388 A CN111143388 A CN 111143388A
Authority
CN
China
Prior art keywords
distributed lock
database
resource
lock
distributed
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
CN201911376842.6A
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.)
Shanghai Mihoyo Tianming Technology Co Ltd
Original Assignee
Shanghai Mihoyo Tianming 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 Shanghai Mihoyo Tianming Technology Co Ltd filed Critical Shanghai Mihoyo Tianming Technology Co Ltd
Priority to CN201911376842.6A priority Critical patent/CN111143388A/en
Publication of CN111143388A publication Critical patent/CN111143388A/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/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a resource processing method, a resource processing device, resource processing equipment and a storage medium. The method comprises the following steps: responding to the setting operation detected by the initiating terminal, and applying for a distributed lock from a database; when the distributed lock application is successful, updating the resources; and if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again. The technical scheme provided by the embodiment of the invention can avoid errors when a plurality of processes on a plurality of hosts process the resources, and can ensure the accuracy of resource updating.

Description

Resource processing method, device, equipment and storage medium
Technical Field
Embodiments of the present invention relate to resource processing technologies, and in particular, to a resource processing method, device, apparatus, and storage medium.
Background
When the resources are processed in a single process on a single host, the resources can be directly updated, and errors can not occur. With the development of internet technology, information is shared, and resources can be processed in multiple processes on multiple hosts.
However, when a resource is processed in multiple processes on multiple hosts, such as the process a updates the resource, and the process B also updates the resource, the update of the resource may be that the process a acquires the current state of the resource to update the resource, and the process B acquires the current state of the resource to update the resource, where the current state of the resource acquired by the process B and the current state of the resource acquired by the process a may be the same. Finally, the update result of the resource may be that the process B updates the resource according to the acquired current state of the resource.
That is, the resource update may not take into account the resource update of process a, and the resource update result is inaccurate. Therefore, in the prior art, errors are easy to occur when a plurality of processes on a plurality of hosts process resources.
Disclosure of Invention
The invention provides a resource processing method, a device, equipment and a storage medium, which can realize that a plurality of processes on a plurality of hosts can correctly process resources.
In a first aspect, an embodiment of the present invention provides a resource processing method, where the method includes:
responding to the setting operation detected by the initiating terminal, and applying for a distributed lock from a database;
when the distributed lock application is successful, updating the resources;
and if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again.
In a second aspect, an embodiment of the present invention further provides a resource processing apparatus, where the apparatus includes:
the distributed lock application module is used for responding to the setting operation detected by the initiating terminal and applying for a distributed lock to the database;
the resource updating module is used for updating the resources when the distributed lock application is successful;
and the distributed lock releasing module is used for releasing the distributed lock to the database if the resource is updated so as to enable other ends to apply for the distributed lock to update the resource again.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the resource processing method provided by any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the resource processing method provided in any embodiment of the present invention.
The invention applies for the distributed lock to the database by responding to the setting operation detected by the initiating terminal; when the distributed lock application is successful, updating the resources; if the resource is updated, the distributed lock is released to the database so that other ends apply for the distributed lock to update the resource again, the problem that in the prior art, multiple processes on multiple hosts are prone to making mistakes when processing the resource is solved, and the effect of correctly processing the resource updating conditions of the multiple processes on the multiple hosts is achieved.
Drawings
Fig. 1a is a flowchart of a resource processing method according to an embodiment of the present invention;
FIG. 1b is a schematic diagram of a process for applying for a distributed lock according to an embodiment of the present invention;
FIG. 1c is a schematic diagram of a process for releasing a distributed lock according to an embodiment of the present invention;
fig. 2a is a flowchart of a resource processing method according to a second embodiment of the present invention;
FIG. 2b is a schematic diagram of a game server applying for a player's money lock according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a resource processing apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1a is a flowchart of a resource processing method according to an embodiment of the present invention, where this embodiment is applicable to a situation where multiple processes on multiple hosts update information of game players, and the method may be executed by a resource processing device, where the device may be implemented by software and/or hardware, and the device may be integrated in a processor, as shown in fig. 1a, where the method specifically includes the following steps:
step 110, responding to the setting operation detected by the initiating terminal, and applying for the distributed lock from the database.
The initiating end may be a server that updates a bank account, a game, or other data, and taking a game server as an example, when the game server detects that information of a game player needs to be updated, the initiating end may apply for a distributed lock from a database, such as a relational database (mysql database). The distributed lock can be used by a plurality of processes on a plurality of hosts, such as a plurality of servers, and when the distributed lock is successfully applied, the game server can update the information of the game player; when the distributed lock application fails, the game server can not update the information of the game player.
In an implementation manner of the embodiment of the present invention, optionally, applying for the distributed lock from the database in response to the setting operation detected by the initiating terminal includes: and applying for the distributed lock from the database in a transaction mode in response to the setting operation detected by the initiating terminal.
The database may be a mysql database, and the transaction property of the mysql database may be utilized, and the distributed lock may be applied to the database in a transaction manner in response to the setting operation detected by the initiator. Transactional properties of the mysql database may include atomicity, consistency, isolation, and durability. The atomicity means that operations contained in the transaction are either all successful or all failed, if all successful, the operations must be applied to the database, and if all failed, the operations cannot have any influence on the database; coherency means that a transaction must transition a database from one coherency state to another; the isolation refers to that when a plurality of users access the database concurrently, the database is a transaction opened by each user and is not interfered by the operation of other transactions; persistence refers to the fact that once a transaction is committed, changes to the data of the database are permanent, and even if the database fails, the operations that committed the transaction are not lost. That is, the application of the distributed lock to the database is successful or failed, if the application is successful, the distributed lock is completely applied to the database, and if the application is failed, the database is not affected; applying for operation of the distributed lock to satisfy integrity constraints; the operation of applying for the distributed lock is not interfered by other transactions; and the change to the database is permanent, which can ensure that the database is not damaged due to partial modification of a transaction, cannot judge the specific state of the database, and can also ensure the reliable execution of the transaction.
In an implementation manner of the embodiment of the present invention, optionally, applying for the distributed lock from the database in response to the setting operation detected by the initiating terminal includes: and in response to the setting operation detected by the initiating terminal, modifying the unallocated distributed lock field in the database into the allocated distributed lock field, or inserting the allocated distributed lock field into the database.
When the initiating end detects the setting operation, the initiating end may apply for the distributed lock from the database, such as the mysql database, specifically, the unallocated distributed lock field in the mysql database may be modified into the allocated distributed lock field in a transaction manner, or the allocated distributed lock field may be inserted into the mysql database in a transaction manner.
And step 120, updating the resources when the distributed lock application is successful.
In an implementation manner of the embodiment of the present invention, optionally, when the distributed lock application is successful, updating the resource includes: and when response information fed back by the database and applied successfully is received, determining that the distributed lock is applied successfully, and updating the resources.
After applying for the distributed lock to the database, the database provides feedback information for the application of the distributed lock, if response information fed back by the database for successful application is received, the application of the distributed lock is successful, and the resource can be updated, wherein the response information for successful application can be response information for successful modification of the distributed lock field or successful insertion of the distributed lock field; if response information fed back by the database and failed to apply is received or response information fed back by the database and succeeded to apply is not received, the distributed lock fails to apply and the resource cannot be updated, wherein the response information failed to apply can be response information failed in modifying the distributed lock field or failed in inserting the distributed lock field.
Fig. 1b is a schematic diagram of a process of applying for a distributed lock according to an embodiment of the present invention, and as shown in fig. 1b, the process of applying for a distributed lock according to an embodiment of the present invention may be to apply for a distributed lock to a database, insert or update distributed lock information in a transaction manner, determine whether insertion or update is successful according to response information fed back by the database, and if successful, apply for a distributed lock successfully, and update resources; if the distributed lock fails, the distributed lock information can be inserted or updated again in a transaction mode until the insertion or the updating is judged to be successful according to the response information fed back by the database, and the resource can be updated.
And step 130, if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again.
When the initiating terminal finishes updating the resources, the distributed lock can be released, and after the release is successful, the initiating terminal can not update the resources. When the other end or the initiating end needs to update the resource, the distributed lock can be applied to the database, such as the mysql database, again.
In an implementation manner of the embodiment of the present invention, optionally, if the resource update is completed, releasing the distributed lock to the database includes: and if the resource is updated, releasing the distributed lock to the database in a transaction mode.
The release of the distributed lock can also release the distributed lock to a database such as a mysql database in a transaction manner, so that the database can be guaranteed to be damaged due to partial modification of one transaction, the specific state of the database cannot be judged, and the execution reliability of the transaction can also be guaranteed.
In an implementation manner of the embodiment of the present invention, optionally, if the resource update is completed, releasing the distributed lock to the database includes: if the resource is updated, judging whether the identification of the initiating terminal applying for the distributed lock is the same as the identification of the local terminal; if the distributed lock fields are the same, the distributed lock fields in the database are modified into the unallocated distributed lock fields, so that the distributed locks at the local end are deleted.
When the initiating terminal finishes updating the resources, the distributed lock can be released, and when the distributed lock is released, whether the identifiers of the initiating terminal of the distributed lock and the local terminal are the same or not needs to be judged, namely whether the initiating terminal successfully applying the current distributed lock releases the distributed lock to the database needs to be judged; if so, the distributed lock field in the database can be modified into the unallocated distributed lock field, the distributed lock of the local terminal can be deleted, and at this time, when other terminals or the initiating terminal need to update the resource, the distributed lock can be applied to the database, such as the mysql database, again; if not, the distributed field in the database can not be modified, the initiating end can continue to update the resources, and other ends cannot update the resources.
Fig. 1c is a schematic diagram of a process of releasing a distributed lock according to an embodiment of the present invention, and as shown in fig. 1c, the process of releasing a distributed lock according to an embodiment of the present invention may be, release a distributed lock to a database in a transaction manner, determine whether an identifier of an originating terminal applying for the distributed lock is the same as an identifier of a home terminal, that is, determine whether the originating terminal applying for the distributed lock is the same as the identifier of the home terminal, and if the originating terminal applying for the distributed lock is the same as the identifier of the home terminal releasing the distributed lock, modify an allocated distributed lock field in the database into an unallocated distributed lock field to delete the distributed lock of the home terminal; if not, the distributed lock field in the database is not modified.
According to the technical scheme of the embodiment, the distributed lock is applied to the database by responding to the setting operation detected by the initiating terminal; when the distributed lock application is successful, updating the resources; if the resource is updated, the distributed lock is released to the database so that other ends apply for the distributed lock to update the resource again, the problem that in the prior art, when multiple processes on multiple hosts process the resource, errors are prone to occurring is solved, and the effect of correctly processing the resource updating conditions of the multiple processes on the multiple hosts is achieved.
Example two
Fig. 2a is a flowchart of a resource processing method provided in a second embodiment of the present invention, which is a further refinement of the foregoing technical solution, and the technical solution in this embodiment may be combined with various alternatives in one or more of the foregoing embodiments.
As shown in fig. 2a, the method specifically includes:
step 210, responding to the setting operation detected by the initiating terminal, and applying for the distributed lock from the database.
In an implementation manner of the embodiment of the present invention, optionally, applying for the distributed lock from the database in response to the setting operation detected by the initiating terminal includes: a monetary lock is applied to the database in response to the game server detecting an operation to update the target player's money.
The resource can be a bank account, game data or other data, and the update of the resource can be a balance update of the bank account, a money update of a player in the game or other data update. Applying for a distributed lock to the database may be transactionally applying for a monetary lock to the database to update the target player money in response to the game server detecting an operation to update the target player money.
Step 220, modifying the unallocated distributed lock field in the database to an allocated distributed lock field, or inserting an allocated distributed lock field into the database.
Wherein the unallocated money lock field in the database may be modified to an allocated money lock field, or an allocated money lock field may be inserted into the database.
And step 230, when response information of successful application fed back by the database is received, determining that the application of the distributed lock is successful, and updating the resource.
In an implementation manner of the embodiment of the present invention, optionally, when the distributed lock application is successful, updating the resource includes: when the money lock application is successful, the target player's money is updated.
When the response message of the successful application of the money lock fed back by the database is received, the success of the application of the money lock can be determined, and the money of the target player in the game can be updated.
And step 240, if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again.
In an implementation manner of the embodiment of the present invention, optionally, if the resource is updated, releasing the distributed lock to the database, so that the other end applies for the distributed lock to update the resource again, including: and if the target player's money is updated, releasing the money lock to the database so that other game servers apply for the money lock to update the target player's money again.
If the target player's money is updated, the money lock can be released to the database in a transaction mode, so that other game servers apply for the money lock to update the target player's money again.
Step 250, judging whether the identification of the initiating terminal applying for the distributed lock is the same as the identification of the home terminal; if the distributed lock fields are the same, the distributed lock fields in the database are modified into the unallocated distributed lock fields, so that the distributed locks at the local end are deleted.
The game server applying for the monetary lock may be determined to be identical to the local terminal, that is, whether the game server applying for the monetary lock is identical to the game server releasing the monetary lock may be determined, and if so, the allocated monetary lock field in the database may be modified to an unallocated monetary lock field to delete the local terminal monetary lock, so that other game servers apply for the monetary lock to update the monetary lock of the target player again.
According to the technical scheme of the embodiment, the distributed lock is applied to the database by responding to the setting operation detected by the initiating terminal; modifying an unallocated monetary lock field in the database to an allocated monetary lock field, or inserting an allocated monetary lock field into the database; updating the target player's money when the monetary lock application is successful; if the target player's money is updated, releasing the money lock to the database; the game server applying for the monetary lock is judged to be identical to the local terminal identification, if so, the allocated monetary lock field in the database is modified to the unallocated monetary lock field to delete the monetary lock of the local terminal, so that other game servers apply for the monetary lock to update the money of the target player again, the problem that errors are easy to occur when concurrent updating operation is carried out on the same player in the prior art is solved, and the effect of concurrent updating on the same player can be correctly realized.
Fig. 2B is a schematic diagram of a game server applying for a monetary lock of a player according to an embodiment of the present invention, and as shown in fig. 2B, there are a plurality of game servers, such as a game server a, a game server B, and a game server N, which need to update a money of the player a.
When the game server a applies for the monetary lock of the player a to the mysql database, the mysql database may feed back the application, for example, feed back response information that the monetary lock application is successful, and at this time, the game server a may update the money of the player a. At this time, the game server B also applies for the money lock of the player A from the mysql database, the mysql database also feeds back the application, at this time, the mysql database already feeds back response information of successful money lock application from the application of the game server A, the mysql database feeds back response information of failed money lock application from the game server B according to the transaction characteristics of the mysql database, the game server B cannot update the money of the player A, and the game server A cannot be interfered to update the money of the player A.
When the game server A's update operation of player A's money is complete, game server A may release player A's money lock. If the game server N applies for the monetary lock of the player a to the mysql database at this time, because the game server a has released the monetary lock of the player a, the mysql database feeds back response information indicating that the monetary lock application is successful to the game server N, and the game server N can update the money of the player a.
At this time, when the game server B applies for the money lock of the player a from the mysql database again, the mysql database feeds back response information indicating that the money lock application is failed to the game server B (because response information indicating that the money lock application is successful has been fed back to the game server N), and at this time, the game server B cannot perform an update operation on the money of the player a, and cannot interfere with the update operation of the money of the player a performed by the game server N.
When the game server N finishes the update operation of player A's money, the game server N may release player A's money lock. At this time, if the game server B applies for the monetary lock of the player a from the mysql database, because the game server N has released the monetary lock of the player a, the mysql database will feed back response information indicating that the monetary lock application is successful to the game server B, and the game server B can update the money of the player a.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a resource processing apparatus according to a third embodiment of the present invention. With reference to fig. 3, the apparatus comprises: a distributed lock application module 310, a resource update module 320, and a distributed lock release module 330.
A distributed lock application module 310, configured to apply for a distributed lock from a database in response to a setting operation detected by an initiator;
the resource updating module 320 is used for updating the resources when the distributed lock application is successful;
the distributed lock releasing module 330 is configured to release the distributed lock to the database if the resource is updated, so that the other end applies for the distributed lock to update the resource again.
In an implementation manner of the embodiment of the present invention, optionally, the distributed lock application module 310 includes:
and the distributed lock field modification unit is used for modifying the unallocated distributed lock field in the database into the allocated distributed lock field or inserting the allocated distributed lock field into the database in response to the setting operation detected by the initiating terminal.
In an implementation manner of the embodiment of the present invention, optionally, the distributed lock releasing module 330 includes:
the identification judgment unit is used for judging whether the identification of the initiating terminal applying the distributed lock is the same as that of the local terminal or not if the resource is updated;
and the distributed lock deleting unit is used for modifying the distributed lock fields in the database into the unallocated distributed lock fields if the distributed lock fields are the same, so as to delete the distributed locks at the local end.
In an implementation manner of the embodiment of the present invention, optionally, the distributed lock application module 310 includes:
the distributed lock application unit is used for responding to the setting operation detected by the initiating terminal and applying for a distributed lock from the database in a transaction mode;
accordingly, distributed lock release module 330 includes:
and the distributed lock releasing unit is used for releasing the distributed lock to the database in a transaction mode if the resource is updated.
In an implementation manner of the embodiment of the present invention, optionally, the resource updating module 320 includes:
and the resource updating unit is used for determining that the application of the distributed lock is successful and updating the resource when response information of successful application fed back by the database is received.
In an implementation manner of the embodiment of the present invention, optionally, the distributed lock application module 310 includes:
a monetary lock application unit for applying a monetary lock to the database in response to an operation of updating the target player's money detected by the game server;
accordingly, the resource update module 320 includes:
the coin updating unit is used for updating the coins of the target player when the application of the money lock is successful;
accordingly, distributed lock release module 330 includes:
and the money lock releasing unit is used for releasing the money lock to the database if the money of the target player is updated, so that other game servers apply for the money lock to update the money of the target player again.
The resource processing device can execute the resource processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 4 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention, and as shown in fig. 4, the computer device includes:
one or more processors 410, one processor 410 being illustrated in FIG. 4;
a memory 420;
the apparatus may further include: an input device 430 and an output device 440.
The processor 410, the memory 420, the input device 430 and the output device 440 of the apparatus may be connected by a bus or other means, for example, in fig. 4.
The memory 420, which is a non-transitory computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to a resource processing method in the embodiment of the present invention (for example, the distributed lock application module 310, the resource update module 320, and the distributed lock release module 330 shown in fig. 3). The processor 410 executes various functional applications and data processing of the computer device by executing software programs, instructions and modules stored in the memory 420, namely, a resource processing method for implementing the above method embodiments, namely:
responding to the setting operation detected by the initiating terminal, and applying for a distributed lock from a database;
when the distributed lock application is successful, updating the resources;
and if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again.
The memory 420 may 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; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 420 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 420 may optionally include memory located remotely from processor 410, which may be connected to the terminal device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 430 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus. The output device 440 may include a display device such as a display screen.
An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a resource processing method according to an embodiment of the present invention:
responding to the setting operation detected by the initiating terminal, and applying for a distributed lock from a database;
when the distributed lock application is successful, updating the resources;
and if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method for processing resources, comprising:
responding to the setting operation detected by the initiating terminal, and applying for a distributed lock from a database;
when the distributed lock application is successful, updating the resources;
and if the resource is updated, releasing the distributed lock to the database so that other ends apply for the distributed lock to update the resource again.
2. The method of claim 1,
responding to the setting operation detected by an initiating terminal, applying for a distributed lock from a database, comprising:
and in response to the setting operation detected by the initiating terminal, modifying the unallocated distributed lock field in the database into the allocated distributed lock field, or inserting the allocated distributed lock field into the database.
3. The method of claim 2,
if the resource is updated, releasing the distributed lock to the database, including:
if the resource is updated, judging whether the identifiers of the originating terminal and the home terminal applying for the distributed lock are the same;
if the distributed lock fields are the same, the distributed lock fields in the database are modified into unallocated distributed lock fields, so that the distributed locks at the local end are deleted.
4. The method of claim 1, wherein applying for the distributed lock from the database in response to the set operation detected by the initiator comprises:
responding to the setting operation detected by the initiating terminal, and applying for a distributed lock from a database in a transaction mode;
if the resource is updated, releasing the distributed lock to the database, including:
and if the resource is updated, releasing the distributed lock to the database in a transaction mode.
5. The method of claim 1,
when the distributed lock application is successful, updating the resources, including:
and when response information fed back by the database and applied successfully is received, determining that the application of the distributed lock is successful, and updating the resource.
6. The method of claim 1,
the responding to the setting operation detected by the initiating terminal, applying for the distributed lock from the database includes:
applying for a monetary lock to the database in response to a game server detecting an operation to update a target player's money;
correspondingly, when the distributed lock application is successful, updating the resource includes:
updating the target player's money when the monetary lock application is successful;
correspondingly, if the resource is updated, releasing the distributed lock to the database so that other terminals apply for the distributed lock to update the resource again, including:
and if the target player's money is updated, releasing the money lock to the database so that other game servers apply for the money lock to update the target player's money again.
7. A resource processing apparatus, comprising:
the distributed lock application module is used for responding to the setting operation detected by the initiating terminal and applying for a distributed lock to the database;
the resource updating module is used for updating the resources when the distributed lock application is successful;
and the distributed lock releasing module is used for releasing the distributed lock to the database if the resource is updated so as to enable other ends to apply for the distributed lock to update the resource again.
8. The apparatus of claim 7, wherein the distributed lock application module comprises:
and the distributed lock field modification unit is used for modifying the unallocated distributed lock field in the database into the allocated distributed lock field or inserting the allocated distributed lock field into the database in response to the setting operation detected by the initiating terminal.
9. A computer device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the resource handling method of any of claims 1-6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the resource processing method according to any one of claims 1 to 6.
CN201911376842.6A 2019-12-27 2019-12-27 Resource processing method, device, equipment and storage medium Pending CN111143388A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911376842.6A CN111143388A (en) 2019-12-27 2019-12-27 Resource processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911376842.6A CN111143388A (en) 2019-12-27 2019-12-27 Resource processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111143388A true CN111143388A (en) 2020-05-12

Family

ID=70521013

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911376842.6A Pending CN111143388A (en) 2019-12-27 2019-12-27 Resource processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111143388A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103997498A (en) * 2014-05-27 2014-08-20 北京京东尚科信息技术有限公司 Distributed lock service implementation method and component
CN106204217A (en) * 2016-07-08 2016-12-07 腾讯科技(深圳)有限公司 The methods, devices and systems of resource numerical value transfer, the method and apparatus of resource numerical value transfer request
CN107145396A (en) * 2016-03-01 2017-09-08 阿里巴巴集团控股有限公司 Distributed lock implementation method and equipment
CN107544850A (en) * 2016-06-29 2018-01-05 百度在线网络技术(北京)有限公司 Method and apparatus for controlling distributed lock
CN109491928A (en) * 2018-11-05 2019-03-19 深圳乐信软件技术有限公司 Buffer control method, device, terminal and storage medium
CN109766324A (en) * 2018-12-14 2019-05-17 东软集团股份有限公司 Control method, device, readable storage medium storing program for executing and the electronic equipment of distributed lock

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103997498A (en) * 2014-05-27 2014-08-20 北京京东尚科信息技术有限公司 Distributed lock service implementation method and component
CN107145396A (en) * 2016-03-01 2017-09-08 阿里巴巴集团控股有限公司 Distributed lock implementation method and equipment
CN107544850A (en) * 2016-06-29 2018-01-05 百度在线网络技术(北京)有限公司 Method and apparatus for controlling distributed lock
CN106204217A (en) * 2016-07-08 2016-12-07 腾讯科技(深圳)有限公司 The methods, devices and systems of resource numerical value transfer, the method and apparatus of resource numerical value transfer request
CN109491928A (en) * 2018-11-05 2019-03-19 深圳乐信软件技术有限公司 Buffer control method, device, terminal and storage medium
CN109766324A (en) * 2018-12-14 2019-05-17 东软集团股份有限公司 Control method, device, readable storage medium storing program for executing and the electronic equipment of distributed lock

Similar Documents

Publication Publication Date Title
TWI734088B (en) Block chain-based transaction processing method and device, and electronic equipment
CN109951547B (en) Transaction request parallel processing method, device, equipment and medium
US11410166B2 (en) Systems and methods for automated decentralized multilateral transaction processing
CN109710695B (en) Transaction request validity identification and initiation method, device, equipment and medium
CN105573828A (en) Operation processing method and device
CN107431687B (en) Inter-process communication in a multi-tenant environment
CN111782669B (en) Method and device for realizing distributed lock and electronic equipment
CN109918191B (en) Method and device for preventing frequency of service request
CN111111214B (en) Game archiving processing method, device and system
CN109951546A (en) Transactions requests processing method, device, equipment and medium based on intelligent contract
CN110866740A (en) Processing method and device for block chain transaction request, electronic equipment and medium
CN107564175A (en) One kind moves back chucking method, moves back card terminal, mobile network operating side and reimbursement terminal
CN112688983A (en) Proxy right management device, terminal device and storage medium
US20080127219A1 (en) Enhancement of assured event delivery mechanism to eliminate external xa store requirement
US20230153289A1 (en) Application driven data change conflict handling system
CN110097680B (en) Lottery drawing method, device, lottery drawing service system, lottery drawing system and storage medium
CN111611767A (en) Verification method and device
US20230370846A1 (en) Method and apparatus for detecting arbitrary account password reset logic vulnerability, and medium
CN107391539B (en) Transaction processing method, server and storage medium
CN112800194A (en) Interface change identification method, device, equipment and storage medium
CN111143388A (en) Resource processing method, device, equipment and storage medium
CN114428815A (en) Data storage method and device, electronic equipment and computer readable medium
US20170308686A1 (en) Authentication method and authentication device
CN110896391B (en) Message processing method and device
CN113609014A (en) Interface field checking method and device, storage medium and electronic equipment

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200512

RJ01 Rejection of invention patent application after publication