CN108958948A - A kind of timer event processing method, database and timer - Google Patents
A kind of timer event processing method, database and timer Download PDFInfo
- Publication number
- CN108958948A CN108958948A CN201810632590.8A CN201810632590A CN108958948A CN 108958948 A CN108958948 A CN 108958948A CN 201810632590 A CN201810632590 A CN 201810632590A CN 108958948 A CN108958948 A CN 108958948A
- Authority
- CN
- China
- Prior art keywords
- timer
- trigger event
- database
- list
- thing
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/524—Deadlock detection or avoidance
Abstract
The embodiment of the present invention provides a kind of timer time processing method, database and timer.It include the request for the trigger event that the timer competes in the lua script this method comprises: receiving the lua script that each timer is sent;According to the lua script execution atomic operation, the corresponding execution data of the trigger event are successively back to corresponding timer.The database is for executing the method.The embodiment of the present invention stores trigger event by database Redis, so that timer is able to carry out spin operation, and according to lua script execution atomic operation, synchronization only allows a timer to have execution permission, and performance caused by locking, unlocking is avoided to be lost.
Description
Technical field
The present invention relates to field of computer technology, in particular to a kind of timer time processing method, database and
Timer.
Background technique
Timer is the software of a multitask timed reminding, it supports WINDOWS9X/ME/NT/2K/XP on time comprehensively
Execute program, play sound, shutdown, standby, dialling, disconnect, closing display etc. operates, therefore in large-scale application system
Use it is very extensive.
The technology being commonly used in the prior art is that distributed lock realizes timing function, realizes timer using distributed lock
It is the main implementation of timer in distributed system, when machine arrives upon activation, multiple timers in cluster must lead to
Cross locking, the mode of unlock obtains execute permission first, then operated by some timers trigger of acquisition permission.For between triggering
It is divided into for the application system of second grade, frequently triggering is very big to the performance loss of system for locking, unlock, and is very easy to make
At deadlock, whole system is caused to be paralysed.
Summary of the invention
In view of this, the embodiment of the present invention is designed to provide a kind of timer time processing method, database and fixed
When device, to solve the above technical problems.
In a first aspect, the embodiment of the invention provides a kind of timer time processing methods, comprising:
The lua script that each timer is sent is received, includes the triggering thing that the timer competes in the lua script
The request of part;
According to the lua script execution atomic operation, successively the corresponding execution data of the trigger event are back to pair
The timer answered.
Further, the method, further includes:
Corresponding multiple list of thing are generated according to the triggered time of the timer, are stored in each list of thing
Triggered time corresponding trigger event information, each trigger event information include trigger event ID and execute number
According to.
Further, successively by the corresponding execution data of the trigger event be back to the corresponding timer it
Afterwards, the method, further includes:
It is to have executed by the status indication of the trigger event.
Second aspect, the embodiment of the invention provides a kind of timer event processing methods, comprising:
The multiple list of thing stored in database Redis are obtained, include multiple triggering things in each list of thing
Part;
If knowing that trigger timing reaches according to triggered time judgement, start the competition triggered time corresponding thing
The spin of the trigger event in part list operates;
The trigger event that competition obtains is sent to the database Redis by lua script.
Further, the method, further includes:
The execution data that the database Redis is returned are received, and the execution data are pulled back into corresponding business mould
Block.
The third aspect, the embodiment of the invention provides a kind of databases, comprising:
Receiving module includes that the timer is competing in the lua script for receiving the lua script of each timer transmission
The request for the trigger event striven;
Return module is used for according to the lua script execution atomic operation, successively by the corresponding execution of the trigger event
Data are back to the corresponding timer.
Further, the database, further includes:
List Generating Module, it is each for generating corresponding multiple list of thing according to the triggered time of the timer
The triggered time corresponding trigger event information is stored in the list of thing, each trigger event information includes
Trigger event ID and execution data.
Further, the database, further includes:
Mark module, for being to have executed by the status indication of the trigger event.
Fourth aspect, the embodiment of the invention provides a kind of timers, comprising:
Module is obtained to wrap in each list of thing for obtaining the multiple list of thing stored in database Redis
Include multiple trigger events;
Module is competed, if for knowing that trigger timing reaches according to triggered time judgement, when starting the competition triggering
Between the trigger event in the corresponding list of thing spin operation;
Sending module, the trigger event for obtaining competition are sent to the database by lua script
Redis。
Further, the timer, further includes:
Callback module, the execution data returned for receiving the database Redis, and the execution data are pulled back to
Corresponding business module.
5th aspect, the embodiment of the present invention provide a kind of electronic equipment, comprising: processor, memory and bus, wherein
The processor and the memory complete mutual communication by the bus;
The memory is stored with the program instruction that can be executed by the processor, and the processor calls described program to refer to
Enable the method and step for being able to carry out first aspect.
6th aspect, the embodiment of the present invention provide a kind of non-transient computer readable storage medium, comprising:
The non-transient computer readable storage medium stores computer instruction, and the computer instruction makes the computer
Execute the method and step of first aspect.
7th aspect, the embodiment of the present invention provide a kind of electronic equipment, comprising: processor, memory and bus, wherein
The processor and the memory complete mutual communication by the bus;
The memory is stored with the program instruction that can be executed by the processor, and the processor calls described program to refer to
Enable the method and step for being able to carry out first aspect.
Eighth aspect, the embodiment of the present invention provide a kind of non-transient computer readable storage medium, comprising:
Computer instruction described in the non-transient computer readable storage medium storage computer instruction makes the computer
Execute the method and step of first aspect.
The embodiment of the present invention stores trigger event by database Redis, so that timer is able to carry out spin operation, and
And according to lua script execution atomic operation, synchronization only allows a timer to have execution permission, avoids locking, unlock
Caused by performance be lost.
Other features and advantages of the present invention will be illustrated in subsequent specification, also, partly be become from specification
It is clear that by implementing understanding of the embodiment of the present invention.The objectives and other advantages of the invention can be by written theory
Specifically noted structure is achieved and obtained in bright book, claims and attached drawing.
Detailed description of the invention
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below will be to needed in the embodiment attached
Figure is briefly described, it should be understood that the following drawings illustrates only certain embodiments of the present invention, therefore is not construed as pair
The restriction of range for those of ordinary skill in the art without creative efforts, can also be according to this
A little attached drawings obtain other relevant attached drawings.
Fig. 1 is a kind of timer event processing method flow diagram provided in an embodiment of the present invention;
Fig. 2 is another timer event processing method flow diagram provided in an embodiment of the present invention;
Fig. 3 is timer event processing method overall flow schematic diagram provided in an embodiment of the present invention;
Fig. 4 is a kind of database structure schematic diagram provided in an embodiment of the present invention;
Fig. 5 is a kind of timer construction schematic diagram provided in an embodiment of the present invention;
Fig. 6 is the structural block diagram of electronic equipment provided in an embodiment of the present invention;
Fig. 7 be another embodiment of the present invention provides electronic equipment structural block diagram.
Specific embodiment
Below in conjunction with attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete
Ground description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Usually exist
The component of the embodiment of the present invention described and illustrated in attached drawing can be arranged and be designed with a variety of different configurations herein.Cause
This, is not intended to limit claimed invention to the detailed description of the embodiment of the present invention provided in the accompanying drawings below
Range, but it is merely representative of selected embodiment of the invention.Based on the embodiment of the present invention, those skilled in the art are not doing
Every other embodiment obtained under the premise of creative work out, shall fall within the protection scope of the present invention.
It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing.Meanwhile of the invention
In description, term " first ", " second " etc. are only used for distinguishing description, are not understood to indicate or imply relative importance.
Fig. 1 is a kind of timer event processing method flow diagram provided in an embodiment of the present invention, as shown in Figure 1, should
Method includes:
Step 101: receiving the lua script that each timer is sent, include that each timer competes in the lua script
The trigger event arrived.
In the specific implementation process, when the corresponding trigger timing of trigger event arrives, for example 10 seconds trigger timings arrive
When coming, all timer starting competitions execute the triggering thing in the list of thing that the triggered time is 10 seconds in entire distributed system
The spin of part operates, thus, the available trigger event to predetermined number of each timer, by the corresponding request of trigger event
It is sent to database Redis by lua script, at this point, database Redis receives the lua script that all timers are sent, is answered
When to be in lua script the include request of trigger event that the timer competes of explanation, and lua script can guarantee one group
The atomicity of operation.
Step 102: according to the lua script execution atomic operation, successively by the corresponding execution data of the trigger event
It is back to the corresponding timer.
In the specific implementation process, database Redis naturally supports lua script, realizes that the atom of one group of operation calls,
Therefore, when database Redis receives multiple lua scripts, only one timer of permission is executed in synchronization
RPOPLPUSH order, that is, guarantee there is execution permission in only one timer of synchronization, and timer executes primary
RPOPLPUSH order can return to unique trigger event ID in a list of thing, and database Redis asks the timer
The execution content for the trigger event asked returns in the timer, and timer pulls back to corresponding after receiving the execution content
Business module.
The embodiment of the present invention stores trigger event by database Redis, so that timer is able to carry out spin operation, and
And according to lua script execution atomic operation, synchronization only allows a timer to have execution permission, avoids locking, unlock
Caused by performance be lost.
On the basis of the above embodiments, the method, further includes:
Corresponding multiple list of thing are generated according to the triggered time of the timer, are stored in each list of thing
Triggered time corresponding trigger event information, each trigger event information include trigger event ID and execute number
According to.
In the specific implementation process, business module is by HTTP request registration timer, and when registration timer will triggering
Time (30s), readjustment http protocol (POST request, url, body) are sent to operation layer.Operation layer randomly selects distributed fixed
When device in a timer, forward a request to the timer.Timer is that trigger event generates a unique triggering thing
Part ID, and this trigger event ID is added in the corresponding list structure of database Redis according to its triggered time, it is assumed that touching
The hair time is 30s, then executes lpush timer:30s ID_ABCD, appoint storage timing in this list of such timer:30s
The ID:ID_ABCD of business.Will be entire using unique trigger event ID as key in request, entire JSON content is stored in database
In Redis, i.e. set ID_ABCD:request (request refers to the entire JSON content that timer receives).In database
Corresponding list of thing is generated according to the timers trigger time in Redis, for example timer is supported 10 seconds, 30 seconds, 1 minute, 3 minutes
Clocked flip is primary, then generates corresponding four list of thing, N number of triggering thing of corresponding time is stored in each list of thing
N number of trigger event that every 10 seconds this systems need to be implemented is stored in part, such as 10 seconds list of thing.
The embodiment of the present invention is by generating corresponding multiple list of thing according to the triggered time, when machine reaches upon activation,
Enable timer to compete the trigger event in corresponding list of thing, realizes spin operation, reduce to distributed system
Performance loss.
It is corresponding being successively back to the corresponding execution data of the trigger event on the basis of the various embodiments described above
After the timer, the method, further includes:
It is to have executed by the status indication of the trigger event.
In the specific implementation process, database Redis is by the execution data of the corresponding trigger event of a certain timer
After being back to the timer, the status indication to the trigger event is to have executed, and indicates the trigger event within this period
It was performed.
The embodiment of the present invention stores trigger event by database Redis, so that timer is able to carry out spin operation, and
And according to lua script execution atomic operation, synchronization only allows a timer to have execution permission, avoids locking, unlock
Caused by performance be lost.
Fig. 2 is another timer event processing method flow diagram provided in an embodiment of the present invention, as shown in Fig. 2,
This method comprises:
Step 201: obtaining the multiple list of thing stored in database Redis, include more in each list of thing
A trigger event.
In the specific implementation process, timer obtains the multiple list of thing stored in database Redis, should illustrate
, can be grown when the list of thing of database Redis is the triggered time according to timer, for example timer supports 10
Second, 30 seconds, 1 minute, 3 minutes clocked flips are primary, then generate corresponding four lists, the corresponding time is stored in each list
N number of trigger event that every 10 seconds this systems need to be implemented is stored in N number of trigger event, such as list in 10 seconds.
Step 202: if knowing that trigger timing reaches according to triggered time judgement, it is corresponding to start the competition triggered time
List of thing in trigger event spin operation.
In the specific implementation process, when some trigger timing arrives, such as the triggered time is 10 seconds, then in system
The trigger event in list of thing that the timer starting competition triggered time is 10 seconds, realizes spin operation.It should be noted that
The number for the trigger event that each timer can compete in competition process is preset, therefore, under normal circumstances, is
Each timer can compete the trigger event of predetermined number in system.
Step 203: the trigger event that competition obtains is sent to the database Redis by lua script.
In the specific implementation process, the corresponding request of trigger event that competition obtains is passed through lua by each timer
Script is sent to database Redis, since database Redis is one process database, and supports the atomic operation of lua script,
Therefore corresponding execution content only is returned to a timer in synchronization, thus to guarantee only one each timer energy
Enough obtain executes permission.
The embodiment of the present invention is by the trigger event in the list of timer competitive events, and by the corresponding request of trigger event
It is sent to database Redis with lua script, so that database Redis guarantees that only one timer of synchronization obtains
Permission is executed, timer is not needed and is locked and unlocked operation, reduce the loss to system performance.
On the basis of the above embodiments, the method, further includes:
The execution data that the database Redis is returned are received, and the execution data are pulled back into corresponding business mould
Block.
In the specific implementation process, timer receives the execution data that database Redis is returned, it is to be understood that
Synchronization can only have a timer to receive corresponding execution data, and receiving the timer for executing data just has right of execution
Limit, therefore, the timer will execute data and pull back to corresponding business module by operation layer.
The embodiment of the present invention is by the trigger event in the list of timer competitive events, and by the corresponding request of trigger event
It is sent to database Redis with lua script, so that database Redis guarantees that only one timer of synchronization obtains
Permission is executed, timer is not needed and is locked and unlocked operation, reduce the loss to system performance.
Fig. 3 is timer event processing method overall flow schematic diagram provided in an embodiment of the present invention, as shown in figure 3, packet
It includes:
Step 1: for business module by HTTP request registration timer, when registration timer, will execute period (30s), readjustment
Http protocol information (POST request, url, body) is sent to operation layer.
Step 2: operation layer randomly selects a timer in distributed timing device, forwards a request to the timer.
Step 3: timer will be in the corresponding data write-in database Redis of the trigger event;
Such as timer A obtains the request of registration timer.
I: a unique trigger event ID:ID_ABCD is generated for trigger event;
Ii: this trigger event ID is added in triggered time corresponding Redis list of thing structure, this time triggers thing
Part is 30s, executes lpush timer:30s ID_ABCD, will store trigger event in this list of thing of such timer:30s
ID:ID_ABCD;
Iii: entire JSON content is stored in redis by entire in request using unique ID as key, set ID_
ABCD:request (request refers to the entire JSON content that timer receives),
Step 4: machine can be when the period arrives in distributed timing device cluster, and (30s per minute) is performed simultaneously and obtains
The data in Redistimer:30s List are taken, timer competition executes the spin behaviour of fixed number data in this list of thing
Make, but only one timer can obtain execution permission.It is return that timer executes a RPUSHLPOP timer:30s order
The unique ID:ID_ABCD stored in a list is returned, while this ID is set and was executed within this period, and obtains this only
The request content of one ID, get ID_ABCD:request.
The corresponding execution data of each timer are successively returned to timer by step 5:Redis.
Step 6: timer is available according to the request of this trigger event when registration timer (i.e. JSON content)
It should be to send POST request, the body of POST request to http://www.a.com to readjustment are as follows:
Step 7: the request of timer is transmitted to corresponding business module by operation layer.
Fig. 4 is a kind of database structure schematic diagram provided in an embodiment of the present invention, as shown in figure 4, the database includes: to connect
Receive module 401 and return module 402, wherein
Receiving module 401 is used to receive the lua script that each timer is sent, and includes the timer in the lua script
Compete the request of obtained trigger event;Return module 402 is used for according to the lua script execution atomic operation, successively by institute
It states the corresponding execution data of trigger event and is back to corresponding timer.
In the specific implementation process, when the corresponding trigger timing of trigger event arrives, for example 10 seconds trigger timings arrive
When coming, all timer starting competitions execute the triggering thing in the list of thing that the triggered time is 10 seconds in entire distributed system
The spin of part operates, thus, the available trigger event to predetermined number of each timer, by the corresponding request of trigger event
It is sent to database Redis by lua script, at this point, receiving module 401 receives the lua script that all timers are sent, is answered
When to be in lua script the include request of trigger event that the timer competes of explanation, and lua script can guarantee one group
The atomicity of operation.Database Redis naturally supports lua script, realizes that the atom of one group of operation calls, therefore, works as database
When Redis receives multiple lua scripts, in synchronization only to allowing a timer to execute RPOPLPUSH order, that is, guarantee
Have in only one timer of synchronization and execute permission, timer, which executes a RPOPLPUSH order, can return to a thing
Unique trigger event ID in part list, and return module 402 returns the execution content of the trigger event of the timer request
It returns in the timer, timer pulls back to corresponding business module after receiving the execution content.
The embodiment of the present invention stores trigger event by database Redis, so that timer is able to carry out spin operation, and
And according to lua script execution atomic operation, synchronization only allows a timer to have execution permission, avoids locking, unlock
Caused by performance be lost.
On the basis of the above embodiments, the database, further includes:
List Generating Module, it is each for generating corresponding multiple list of thing according to the triggered time of the timer
The triggered time corresponding trigger event information is stored in the list of thing, each trigger event information includes triggering
Event id and execution data.
On the basis of the above embodiments, the database, further includes:
Mark module, for being to have executed by the status indication of the trigger event.
It is apparent to those skilled in the art that for convenience and simplicity of description, the device of foregoing description
Specific work process, no longer can excessively be repeated herein with reference to the corresponding process in preceding method.
In conclusion the embodiment of the present invention stores trigger event by database Redis, so that timer is able to carry out certainly
Rotation operation, and according to lua script execution atomic operation, synchronization only allows a timer to have execution permission, avoids
It locks, performance caused by unlock is lost.
Fig. 5 is a kind of timer construction schematic diagram provided in an embodiment of the present invention, as shown in figure 5, the timer includes: to obtain
Modulus block 501, competition module 502 and sending module 503, wherein
Module 501 is obtained for obtaining the multiple list of thing stored in database Redis, in each list of thing
Including multiple trigger events;If competition module 502 is used to know that trigger timing reaches according to triggered time judgement, start competition
The spin operation of trigger event in triggered time corresponding list of thing;Sending module 503 is used to compete to obtain
The trigger event is sent to the database Redis by lua script.
In the specific implementation process, it obtains module 501 and obtains the multiple list of thing stored in database Redis, answer
It when explanation, can be grown when the list of thing of database Redis is the triggered time according to timer, such as timer branch
Hold 10 seconds, 30 seconds, 1 minute, 3 minutes clocked flips it is primary, then generate corresponding four lists, in each list storage to it is corresponding when
Between N number of trigger event, for example N number of trigger event that every 10 seconds this systems need to be implemented is stored in list in 10 seconds.When some
When trigger timing arrives, such as the triggered time is 10 seconds, then competes the event column that the starting competition triggered time of module 502 is 10 seconds
Trigger event in table realizes spin operation.The corresponding request of trigger event that competition obtains is passed through lua by sending module 503
Script is sent to database Redis, since database Redis is one process database, and supports the atomic operation of lua script,
Therefore corresponding execution content only is returned to a timer in synchronization, thus to guarantee only one each timer energy
Enough obtain executes permission.
The embodiment of the present invention is by the trigger event in the list of timer competitive events, and by the corresponding request of trigger event
It is sent to database Redis with lua script, so that database Redis guarantees that only one timer of synchronization obtains
Permission is executed, timer is not needed and is locked and unlocked operation, reduce the loss to system performance.
On the basis of the above embodiments, the timer, further includes:
Callback module, the execution data returned for receiving the database Redis, and the execution data are pulled back to
Corresponding business module.
It is apparent to those skilled in the art that for convenience and simplicity of description, the device of foregoing description
Specific work process, no longer can excessively be repeated herein with reference to the corresponding process in preceding method.
In conclusion the embodiment of the present invention is by the trigger event in the list of timer competitive events, and by trigger event
Corresponding request with lua script is sent to database Redis so that database Redis guarantee synchronization only one
Timer, which obtains, executes permission, does not need timer and is locked and unlocked operation, reduces the loss to system performance.
Fig. 6 is please referred to, Fig. 6 is the structural block diagram of electronic equipment provided in an embodiment of the present invention.Electronic equipment may include
Database 601, memory 602, storage control 603, processor 604, Peripheral Interface 605, input-output unit 606, audio
Unit 607, display unit 608.
The memory 602, storage control 603, processor 604, Peripheral Interface 605, input-output unit 606, sound
Frequency unit 607, each element of display unit 608 are directly or indirectly electrically connected between each other, to realize the transmission or friendship of data
Mutually.It is electrically connected for example, these elements can be realized between each other by one or more communication bus or signal wire.The data
Library 601 includes that at least one can be stored in the memory 602 or be solidificated in the form of software or firmware (firmware)
Software function module in the operating system (operating system, OS) of database 601.The processor 604 is for holding
The executable module stored in line storage 602, such as software function module or computer program that database 601 includes.
Wherein, memory 602 may be, but not limited to, random access memory (Random Access Memory,
RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only
Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM),
Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..
Wherein, memory 602 is for storing program, and the processor 604 executes described program after receiving and executing instruction, aforementioned
Method performed by the server that the stream process that any embodiment of the embodiment of the present invention discloses defines can be applied to processor 604
In, or realized by processor 604.
Processor 604 can be a kind of IC chip, the processing capacity with signal.Above-mentioned processor 604 can
To be general processor, including central processing unit (Central Processing Unit, abbreviation CPU), network processing unit
(Network Processor, abbreviation NP) etc.;Can also be digital signal processor (DSP), specific integrated circuit (ASIC),
Ready-made programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hard
Part component.It may be implemented or execute disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor
It can be microprocessor or the processor 604 be also possible to any conventional processor etc..
Various input/output devices are couple processor 604 and memory 602 by the Peripheral Interface 605.Some
In embodiment, Peripheral Interface 605, processor 604 and storage control 603 can be realized in one single chip.Other one
In a little examples, they can be realized by independent chip respectively.
Input-output unit 606 realizes user and the server (or local terminal) for being supplied to user input data
Interaction.The input-output unit 606 may be, but not limited to, mouse and keyboard etc..
Audio unit 607 provides a user audio interface, may include one or more microphones, one or more raises
Sound device and voicefrequency circuit.
Display unit 608 provides an interactive interface (such as user interface) between the electronic equipment and user
Or it is referred to for display image data to user.In the present embodiment, the display unit 608 can be liquid crystal display or touching
Control display.It can be the touching of the capacitance type touch control screen or resistance-type of support single-point and multi-point touch operation if touch control display
Control screen etc..Single-point and multi-point touch operation is supported to refer to that touch control display can sense on the touch control display one or more
The touch control operation generated simultaneously at a position, and the touch control operation that this is sensed transfers to processor 604 to be calculated and handled.
Various input/output devices are couple processor 604 and memory 602 by the Peripheral Interface 605.Some
In embodiment, Peripheral Interface 605, processor 604 and storage control 603 can be realized in one single chip.Other one
In a little examples, they can be realized by independent chip respectively.
Input-output unit 606 is used to be supplied to the interaction that user input data realizes user and processing terminal.It is described defeated
Entering output unit 606 may be, but not limited to, mouse and keyboard etc..
It is appreciated that structure shown in fig. 6 is only to illustrate, the electronic equipment may also include it is more than shown in Fig. 6 or
The less component of person, or with the configuration different from shown in Fig. 6.Each component shown in Fig. 6 can using hardware, software or
A combination thereof is realized.
Please refer to Fig. 7, Fig. 7 be another embodiment of the present invention provides electronic equipment structural block diagram.Electronic equipment can be with
Including timer 701, memory 702, storage control 703, processor 704, Peripheral Interface 705, input-output unit 706,
Audio unit 707, display unit 708.
The memory 702, storage control 703, processor 704, Peripheral Interface 705, input-output unit 706, sound
Frequency unit 707, each element of display unit 708 are directly or indirectly electrically connected between each other, to realize the transmission or friendship of data
Mutually.It is electrically connected for example, these elements can be realized between each other by one or more communication bus or signal wire.The timing
Device 701 includes that at least one can be stored in the memory 702 or be solidificated in the form of software or firmware (firmware)
Software function module in the operating system (operating system, OS) of timer 701.The processor 704 is for holding
The executable module stored in line storage 702, such as software function module or computer program that timer 701 includes.
Wherein, memory 702 may be, but not limited to, random access memory (Random Access Memory,
RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only
Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM),
Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..
Wherein, memory 702 is for storing program, and the processor 704 executes described program after receiving and executing instruction, aforementioned
Method performed by the server that the stream process that any embodiment of the embodiment of the present invention discloses defines can be applied to processor 704
In, or realized by processor 704.
Processor 704 can be a kind of IC chip, the processing capacity with signal.Above-mentioned processor 704 can
To be general processor, including central processing unit (Central Processing Unit, abbreviation CPU), network processing unit
(Network Processor, abbreviation NP) etc.;Can also be digital signal processor (DSP), specific integrated circuit (ASIC),
Ready-made programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hard
Part component.It may be implemented or execute disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor
It can be microprocessor or the processor 704 be also possible to any conventional processor etc..
Various input/output devices are couple processor 704 and memory 702 by the Peripheral Interface 705.Some
In embodiment, Peripheral Interface 705, processor 704 and storage control 703 can be realized in one single chip.Other one
In a little examples, they can be realized by independent chip respectively.
Input-output unit 706 realizes user and the server (or local terminal) for being supplied to user input data
Interaction.The input-output unit 706 may be, but not limited to, mouse and keyboard etc..
Audio unit 707 provides a user audio interface, may include one or more microphones, one or more raises
Sound device and voicefrequency circuit.
Display unit 708 provides an interactive interface (such as user interface) between the electronic equipment and user
Or it is referred to for display image data to user.In the present embodiment, the display unit 708 can be liquid crystal display or touching
Control display.It can be the touching of the capacitance type touch control screen or resistance-type of support single-point and multi-point touch operation if touch control display
Control screen etc..Single-point and multi-point touch operation is supported to refer to that touch control display can sense on the touch control display one or more
The touch control operation generated simultaneously at a position, and the touch control operation that this is sensed transfers to processor 704 to be calculated and handled.
Various input/output devices are couple processor 704 and memory 702 by the Peripheral Interface 705.Some
In embodiment, Peripheral Interface 705, processor 704 and storage control 703 can be realized in one single chip.Other one
In a little examples, they can be realized by independent chip respectively.
Input-output unit 706 is used to be supplied to the interaction that user input data realizes user and processing terminal.It is described defeated
Entering output unit 706 may be, but not limited to, mouse and keyboard etc..
It is appreciated that structure shown in Fig. 7 is only to illustrate, the electronic equipment may also include it is more than shown in Fig. 7 or
The less component of person, or with the configuration different from shown in Fig. 7.Each component shown in fig. 7 can using hardware, software or
A combination thereof is realized.
In several embodiments provided herein, it should be understood that disclosed device and method can also pass through
Other modes are realized.The apparatus embodiments described above are merely exemplary, for example, flow chart and block diagram in attached drawing
Show the device of multiple embodiments according to the present invention, the architectural framework in the cards of method and computer program product,
Function and operation.In this regard, each box in flowchart or block diagram can represent the one of a module, section or code
Part, a part of the module, section or code, which includes that one or more is for implementing the specified logical function, to be held
Row instruction.It should also be noted that function marked in the box can also be to be different from some implementations as replacement
The sequence marked in attached drawing occurs.For example, two continuous boxes can actually be basically executed in parallel, they are sometimes
It can execute in the opposite order, this depends on the function involved.It is also noted that every in block diagram and or flow chart
The combination of box in a box and block diagram and or flow chart can use the dedicated base for executing defined function or movement
It realizes, or can realize using a combination of dedicated hardware and computer instructions in the system of hardware.
In addition, each functional module in each embodiment of the present invention can integrate one independent portion of formation together
Point, it is also possible to modules individualism, an independent part can also be integrated to form with two or more modules.
It, can be with if the function is realized and when sold or used as an independent product in the form of software function module
It is stored in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially in other words
The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a
People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention.
And storage medium above-mentioned includes: that USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic or disk.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, made any to repair
Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.It should also be noted that similar label and letter exist
Similar terms are indicated in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, are then not required in subsequent attached drawing
It is further defined and explained.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to
Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
There is also other identical elements in process, method, article or equipment including the element.
Claims (10)
1. a kind of timer event processing method characterized by comprising
The lua script that each timer is sent is received, includes the trigger event that the timer competes in the lua script
Request;
According to the lua script execution atomic operation, successively the corresponding execution data of the trigger event are back to corresponding
Timer.
2. the method according to claim 1, wherein the method, further includes:
Corresponding multiple list of thing are generated according to the triggered time of the timer, in each list of thing described in storage
Triggered time corresponding trigger event information, each trigger event information include trigger event ID and execution data.
3. method according to claim 1 or 2, which is characterized in that successively by the corresponding execution number of the trigger event
After being back to the corresponding timer, the method, further includes:
It is to have executed by the status indication of the trigger event.
4. a kind of timer event processing method characterized by comprising
The multiple list of thing stored in database Redis are obtained, include multiple trigger events in each list of thing;
If knowing that trigger timing reaches according to triggered time judgement, start in the competition triggered time corresponding list of thing
Trigger event spin operation;
The trigger event that competition obtains is sent to the database Redis by lua script.
5. according to the method described in claim 4, it is characterized in that, the method, further includes:
The execution data that the database Redis is returned are received, and the execution data are pulled back into corresponding business module.
6. a kind of database characterized by comprising
Receiving module includes that the timer competes in the lua script for receiving the lua script of each timer transmission
The request of the trigger event arrived;
Return module is used for according to the lua script execution atomic operation, successively by the corresponding execution data of the trigger event
It is back to corresponding timer.
7. database according to claim 6, which is characterized in that the database, further includes:
List Generating Module, it is each described for generating corresponding multiple list of thing according to the triggered time of the timer
The triggered time corresponding trigger event information is stored in list of thing, each trigger event information includes trigger event
ID and execution data.
8. database according to claim 6 or 7, which is characterized in that the database, further includes:
Mark module, for being to have executed by the status indication of the trigger event.
9. a kind of timer characterized by comprising
Module is obtained, includes more in each list of thing for obtaining the multiple list of thing stored in database Redis
A trigger event;
Module is competed, if starting the competition triggered time pair for knowing that trigger timing reaches according to triggered time judgement
The spin for the trigger event in list of thing answered operates;
Sending module, the trigger event for obtaining competition are sent to the database Redis by lua script.
10. timer according to claim 9, which is characterized in that the timer, further includes:
Callback module, the execution data returned for receiving the database Redis, and the execution data are pulled back into correspondence
Business module.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810632590.8A CN108958948A (en) | 2018-06-19 | 2018-06-19 | A kind of timer event processing method, database and timer |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810632590.8A CN108958948A (en) | 2018-06-19 | 2018-06-19 | A kind of timer event processing method, database and timer |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108958948A true CN108958948A (en) | 2018-12-07 |
Family
ID=64491184
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810632590.8A Pending CN108958948A (en) | 2018-06-19 | 2018-06-19 | A kind of timer event processing method, database and timer |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108958948A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110502527A (en) * | 2019-08-26 | 2019-11-26 | 深圳前海环融联易信息科技服务有限公司 | Method, apparatus, computer equipment and the storage medium of background request anti-replay |
CN111143361A (en) * | 2019-12-19 | 2020-05-12 | 广州华多网络科技有限公司 | Method and system for writing feature data of online training |
CN111163145A (en) * | 2019-12-23 | 2020-05-15 | 北京数衍科技有限公司 | Distributed data timing and uniform sending method and device and electronic equipment |
WO2021000758A1 (en) * | 2019-07-04 | 2021-01-07 | 中国建设银行股份有限公司 | Robotic resource task cycle management and control method and apparatus |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20030004157A (en) * | 2002-10-01 | 2003-01-14 | 주식회사 비트컴퓨터 | Method for generating meta data to provide moving image educational information |
CN103793273A (en) * | 2014-01-24 | 2014-05-14 | 北京京东尚科信息技术有限公司 | Distributed type queue scheduling method and device based on Redis |
CN105550052A (en) * | 2015-12-28 | 2016-05-04 | 东软集团股份有限公司 | Distributed lock realization method and apparatus |
CN106202505A (en) * | 2016-07-20 | 2016-12-07 | 北京京东尚科信息技术有限公司 | Data processing method and system thereof |
CN106682004A (en) * | 2015-11-06 | 2017-05-17 | 网宿科技股份有限公司 | Redis Key management method and system |
-
2018
- 2018-06-19 CN CN201810632590.8A patent/CN108958948A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20030004157A (en) * | 2002-10-01 | 2003-01-14 | 주식회사 비트컴퓨터 | Method for generating meta data to provide moving image educational information |
CN103793273A (en) * | 2014-01-24 | 2014-05-14 | 北京京东尚科信息技术有限公司 | Distributed type queue scheduling method and device based on Redis |
CN106682004A (en) * | 2015-11-06 | 2017-05-17 | 网宿科技股份有限公司 | Redis Key management method and system |
CN105550052A (en) * | 2015-12-28 | 2016-05-04 | 东软集团股份有限公司 | Distributed lock realization method and apparatus |
CN106202505A (en) * | 2016-07-20 | 2016-12-07 | 北京京东尚科信息技术有限公司 | Data processing method and system thereof |
Non-Patent Citations (5)
Title |
---|
HRY2015: "Redis系列二 - 通过redis命令和lua实现分布式锁", 《HTTPS://BLOG.CSDN.NET/HRY2015/ARTICLE/DETAILS/74937375》 * |
HRY2015: "Redis系列四 - 在springboot中通过Lua脚本在redis中实现定时任务", 《HTTPS://BLOG.CSDN.NET/HRY2015/ARTICLE/DETAILS/76167016》 * |
XI_NUO: "java定时器及利用redis加锁应对分布式", 《HTTPS://BLOG.CSDN.NET/XI_NUO/ARTICLE/DETAILS/80255646》 * |
企鹅号-JAVASOSO: "redis实现可重入分布式锁", 《HTTPS://CLOUD.TENCENT.COM/DEVELOPER/NEWS/16363》 * |
矿泉水: "redis实现分布式锁的演进", 《HTTPS://CLOUD.TENCENT.COM/DEVELOPER/ARTICLE/1130833》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021000758A1 (en) * | 2019-07-04 | 2021-01-07 | 中国建设银行股份有限公司 | Robotic resource task cycle management and control method and apparatus |
CN110502527A (en) * | 2019-08-26 | 2019-11-26 | 深圳前海环融联易信息科技服务有限公司 | Method, apparatus, computer equipment and the storage medium of background request anti-replay |
CN111143361A (en) * | 2019-12-19 | 2020-05-12 | 广州华多网络科技有限公司 | Method and system for writing feature data of online training |
CN111143361B (en) * | 2019-12-19 | 2023-11-14 | 广州方硅信息技术有限公司 | Characteristic data writing method and system for online training |
CN111163145A (en) * | 2019-12-23 | 2020-05-15 | 北京数衍科技有限公司 | Distributed data timing and uniform sending method and device and electronic equipment |
CN111163145B (en) * | 2019-12-23 | 2022-04-05 | 北京数衍科技有限公司 | Distributed data timing and uniform sending method and device and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108958948A (en) | A kind of timer event processing method, database and timer | |
US9177035B2 (en) | Replicating data to a database | |
CN107025713B (en) | The implementation method and device of electronic voting in instant messaging group chat scene | |
CN107634993B (en) | A kind of information push event-handling method, device and electronic equipment | |
CN110309161B (en) | Data synchronization method and device and server | |
CN108292274B (en) | Action execution control server, and control method and collaboration system thereof | |
Magee et al. | Analysing the behaviour of distributed software architectures: a case study | |
CN104182223B (en) | Clocking method and time set | |
CN109857427A (en) | Configure update method and Related product | |
GB2523357A (en) | Shared resource updating method and system | |
TW201015440A (en) | Lock windows for reducing contention | |
CN106502709B (en) | Applied business reminding method and applied business suggestion device | |
CN113760513A (en) | Distributed task scheduling method, device, equipment and medium | |
CN110163572A (en) | A kind of chain code function processing method, device and equipment | |
CN107679381B (en) | A kind of notification information processing method and mobile terminal | |
CN114650320B (en) | Task scheduling method and device, storage medium and electronic equipment | |
CN109558297A (en) | EMS memory management process and device | |
JP2013045356A (en) | Transaction simultaneous execution control system, transaction simultaneous execution control method, and program | |
CN107003927A (en) | High-performance mechanism for producing the log information on computer processes | |
Helmi et al. | The space complexity of long-lived and one-shot timestamp implementations | |
CN109167819A (en) | Data synchronous system, method, apparatus and storage medium | |
CN103782277A (en) | Method and system for managing parallel resource requests in a portable computing device | |
CN110096284A (en) | A kind of method, apparatus, electronic equipment and the storage medium of visualization publication software | |
Joung et al. | Strong interaction fairness via randomization | |
CN110517091A (en) | Poly- screen put-on method, device, equipment and medium based on block chain |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20181207 |