Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings. The embodiments and features of the embodiments in the present disclosure may be combined with each other without conflict.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
FIG. 1 is a schematic diagram of one application scenario of a method for synchronizing data, in accordance with some embodiments of the present disclosure; in the application scenario of fig. 1, the execution agent may be a thread. The execution main body receives input data input by a user on a target terminal and acquires a data identifier of the input data. And determining whether the data identifier exists in the cache, if so, determining whether the state value of the data identifier changes, if so, determining whether the data identifier and the input data exist in the database, and if so, storing the data identifier and the state value into the cache. And if the data identifier does not exist, determining whether the data identifier and the state value exist in the database, and if the data identifier and the state value do not exist, generating the data identifier and the state value in a cache, and synchronously storing the data identifier and the state value in the database. By way of example, it may be that a worker modifies a person's name on a corporate person registry and the input data may be the name to be modified. For example, originally "Zhang shan", modified to "Zhang shan". Here, the data identification may be the employee's job number, e.g., "0001". When the worker clicks on save and/or refresh after modification, the executive entity will find the buffer zone to look for "0001" and the status value will change because the data is modified. The execution subject will look up job number "0001" in the database, and if no job number "0001" exists in the database, the job number "0001" and the state value corresponding to the job number are generated in the cache region. And storing the generated job number, state value and name into a database.
The execution main body may be hardware or software. When the execution main body is hardware, the execution main body can be implemented as a distributed cluster consisting of a plurality of servers or terminal devices, and can also be implemented as a single server or a single terminal device. When the execution body is embodied as software, it may be implemented as a plurality of software or software modules for providing distributed services, for example, or as a single software or software module. But also a thread or process. And is not particularly limited herein.
With continued reference to fig. 2, a flow 200 of some embodiments of a method for synchronizing data in accordance with the present disclosure is shown. The method for synchronizing data comprises the following steps:
step 201, receiving input data input by a user on a target terminal.
In some embodiments, the executive may receive input data entered by the user on the target terminal. The target terminal may be a terminal within the enterprise that is capable of viewing and modifying internal data. Such as a company data monitoring personnel computer. The input data may be employee information added or modified. Employee information may include, but is not limited to, at least one of: job number, name, department, job title, etc. For example, a piece of employee information is added. The job number may be "1001" and the name may be "lie".
Step 202, acquiring the data identifier of the input data.
In some embodiments, the execution subject obtains a data identification of the input data. The data identification is typically an identification corresponding to the input data. Taking the above example as an example, the data identifier may be a job number.
Step 203, determining whether the data identifier exists in the cache of the target terminal according to the data identifier.
In some embodiments, the execution subject may search, according to the obtained data identifier, whether the data identifier exists in the cache region. Taking the above example as an example, a piece of employee information is added, and since the job number and the name are both added, the data identifier in the cache area does not exist. If the name in the employee information is modified, for example, the name of the employee with the employee number "0001" is modified to "lie". Because the job number is already present and the name is modified, the data identification is present.
Step 204, in response to determining that the data identifier exists in the cache of the target terminal, determining whether a state value of the data identifier in the cache changes.
In some embodiments, the execution subject may determine whether a state value of the data identifier changes according to the data identifier. The above state value is generally used to characterize the time from the last use of the data, and the state value is larger the longer the time, for example, when a piece of data is newly added, the state value may be "1". As an example, the input data may be to modify a name in the employee information, e.g., to modify the name of an employee with an employee number of "0001" as "lie". Because the job number is already present and the name is modified, the data identification is present, but the input data is not. The state value of the data identity typically changes. And if no input data exists, only refreshing the page of the display data on the target terminal. Then the data identity is already present and the input data is also already present and the state value of the data identity is not normally changed.
In some optional implementation manners of some embodiments, in response to determining that the data identifier does not exist in the cache of the target terminal, whether the data identifier and the input data exist in a database storing data on the target terminal is determined according to the data identifier. For example, if the staff adds the staff information to the target terminal or the staff directly adds the staff information to the database, the data identifier may not exist in the cache.
Step 205, in response to determining that the change occurs, determining whether the data identifier and the input data exist in a database of data stored on the target terminal according to the data identifier.
In some embodiments, the execution subject may search the database for the presence of the data identifier according to the data identifier when the status value of the data identifier changes. As an example, the input data may be a name in the modified employee information, and the status value of the data identification will typically change. The data identification described above, e.g., job number "0001", is typically found in a database. The input data is typically not found in the database.
In some optional implementations of some embodiments, in response to determining that no change has occurred, sending, to the target terminal, a prompt that a state value of a data identifier characterizing the input data is not updated. The prompt information may be information indicating that the state value of the data identifier representing the input data is not updated, for example, "state value is not updated".
Step 206, in response to determining that the data identifier and the input data exist in the database, synchronously saving the data identifier and the state value of the data identifier in the database into the cache.
In some embodiments, the data identification and the input data are based on the presence of the database. And synchronously storing the data identifier in the database and the state value of the data identifier in the cache. As an example, when the staff directly adds the staff information to the database and refreshes the staff information on the target terminal, the data identifier and the input data corresponding to the input data may not exist in the cache, but the data identifier and the input data corresponding to the input data may exist in the database. At this time, the data identifier corresponding to the input data in the database and the state value of the data identifier may be saved in the cache.
In some optional implementations of some embodiments, in response to determining that the data identifier and the input data do not exist in the stored number database, generating a data identifier of the input data and a state value of the data identifier in a cache of the target terminal; and synchronously storing the data identifier of the input data and the state value of the data identifier into the database. As an example, when the staff adds the staff information to the target terminal, the data identifier and the input data may not exist in the database. The execution subject may invoke a thread to generate a data identifier of the input data and a state value of the data identifier in a cache according to the input data. And storing the generated data identification and the state value of the data identification into the database.
In some optional implementations of some embodiments, further reference may be made to fig. 3, which illustrates aflow 300 of further embodiments of a method for synchronizing data according to the present disclosure. The method for synchronizing data comprises the following steps:
step 301, receiving data input by a user on a target input page.
In some embodiments, the execution principal may receive user input data on the target input page. The target input page may be a page where data operations may be performed on the database. The data operations include, but are not limited to, at least one of: a lookup operation, an add operation, a modify operation, and a delete operation. The data may be data in a database table, for example. Employee names in an employee information table.
Step 302, determining whether the data exists in the database.
In some embodiments, the database is queried for the data received instep 301 to determine whether the data exists in the database. Here, the execution body may look up the above data in a database.
Step 303, in response to determining that the data does not exist in the database, generating a data identifier of the data and a state value of the data identifier according to the data.
In some embodiments, based on determining that the data does not exist in the database, the execution principal may generate a data identifier of the data and a status value of the data identifier from the data.
In some optional implementations of some embodiments, the status value of the data identification of the data is updated in response to determining that the data exists in the database. Here, when the data exists in the database, the execution principal generally updates the state value of the data identifier of the data. For example, the status value of the data identifier of the data is originally "10", and the executing entity may update the status value of the data identifier of the data to "1" because the lookup operation is performed on the data.
Step 304, synchronously storing the data identifier of the data in the database and the state value of the data identifier in the cache.
In some embodiments, the data identifier of the data and the state value of the data identifier generated instep 303 are saved in the cache.
In some optional implementation manners of some embodiments, when the state value of the data identifier in the cache of the target terminal is greater than or equal to a preset threshold, a prompt message for deleting the data identifier corresponding to the state value of the data identifier in the cache of the target terminal is generated. And sending the prompt information to the terminal equipment for monitoring data. Here, the preset threshold may be set manually. The prompt information may be information for prompting deletion of the data identification, for example, "please delete the present data identification". The terminal device for monitoring data may be a device having the authority to monitor data, for example, a computer of a staff member for monitoring data inside an enterprise.
Some embodiments of the present disclosure disclose a method for synchronizing data, which enables synchronized storage of data identifiers and state values of the data identifiers in a cache and a database. Therefore, the memory consumption is reduced when the data is quickly searched and refreshed, and the working efficiency is improved.
With further reference to fig. 4, as an implementation of the above-described method for the above-described figures, the present disclosure provides some embodiments of an apparatus for synchronizing data, which correspond to those of the method embodiments described above for fig. 2, and which may be applied in particular to various electronic devices.
As shown in fig. 4, an apparatus 400 for synchronizing data of some embodiments includes: a first receiving unit 401, an obtaining unit 402, a cache determination existence unit 403, a determination change unit 404, a database determination existence unit 405, and a cache synchronization unit 406. The first unit 401 is configured to receive input data input by a user on a target terminal; an obtaining unit 402 configured to obtain a data identifier of the input data; a cache determination existence unit 403 configured to determine whether the data identifier exists in the cache of the target terminal according to the data identifier; a change determining unit 404 configured to determine whether a state value of the data identifier in the cache changes in response to determining that the data identifier exists in the cache of the target terminal; a database determination existence unit 405 configured to determine whether the data identifier and the input data exist in a database storing data on the target terminal according to the data identifier in response to determining that the change occurs; a buffer synchronization unit 406, configured to, in response to determining that the data identifier and the input data exist in a database storing data on the target terminal, synchronously store the data identifier in the database and a state value of the data identifier in the buffer.
In some embodiments, the apparatus 400 for synchronizing data further comprises: and the cache determining and non-existing unit is configured to respond to the fact that the data identifier does not exist in the cache of the target terminal, and determine whether the data identifier and the state value of the data identifier exist in a database storing data on the target terminal or not according to the data identifier.
In some embodiments, the apparatus 400 for synchronizing data further comprises: a database determination existence unit configured to generate a data identifier of the input data and a state value of the data identifier in a cache of the target terminal in response to a determination that the data identifier and the input data do not exist in a database storing data; and the database synchronization unit is configured to synchronously save the data identifier of the input data and the state value of the data identifier into the database.
In some embodiments, the apparatus 400 for synchronizing data further comprises: and the determining unchanged unit is used for responding to the determination that the change does not occur and sending prompt information which is used for representing that the state value of the data identification of the input data is not updated to the target terminal.
In some embodiments, the apparatus 400 for synchronizing data further comprises: a second receiving unit configured to receive data input by a user on the target input page; a determination unit configured to determine whether the data exists in the database; a generating unit configured to generate a data identifier of the data and a state value of the data identifier according to the data in response to determining that the data does not exist in the database; and the storage unit is configured to synchronously store the data identifier of the data in the database and the state value of the data identifier into the cache.
In some embodiments, the apparatus 400 for synchronizing data further comprises: an updating unit configured to update a state value of a data identifier of the data in response to determining that the data exists in the database.
In some embodiments, the apparatus 400 for synchronizing data further comprises: a prompt unit configured to generate prompt information for deleting a data identifier corresponding to a state value of a data identifier in a cache of the target terminal in response to the state value of the data identifier in the cache of the target terminal being greater than or equal to a preset threshold value; and the sending unit is configured to send the prompt information to the terminal equipment for monitoring data.
Referring now to fig. 5, a block diagram of an electronic device (e.g., the terminal device of fig. 1) 500 suitable for use in implementing some embodiments of the present disclosure is shown. The terminal device in some embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present disclosure.
As shown in fig. 5, electronic device 500 may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the electronic apparatus 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; a storage device 508 including, for example, a memory card; and a communication device 509. The communication means 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device 500 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 5 may represent one device or may represent multiple devices as desired.
In particular, according to some embodiments of the present disclosure, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, some embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In some such embodiments, the computer program may be downloaded and installed from a network via the communication means 509, or installed from the storage means 508, or installed from the ROM 502. The computer program, when executed by the processing device 501, performs the above-described functions defined in the methods of some embodiments of the present disclosure.
It should be noted that the computer readable medium described above in some embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. 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 of the computer readable storage medium may include, but are not limited to: 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 some embodiments of the disclosure, 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. In some embodiments of the present disclosure, however, 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 many 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: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving input data input by a user on a target terminal; acquiring a data identifier of the input data; determining whether the input data exists in the cache of the target terminal according to the data identifier; in response to determining that the input data exists in the cache of the target terminal, determining whether a state value of the data identifier in the cache changes; in response to the determination that the change occurs, determining whether the data identifier and the state value of the data identifier exist in a database storing data on the target terminal according to the data identifier; and responding to the data identification and the state value of the data identification in a database for storing data on the target terminal, calling a cache service, and synchronously storing the data identification and the state value of the data identification in the database into the cache.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, 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).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in some embodiments of the present disclosure may be implemented by software, and may also be implemented by hardware. The described units may also be provided in a processor, and may be described as: a processor includes a first receiving unit, an obtaining unit, a cache existence determining unit, a change determining unit, a database existence determining unit, and a cache synchronizing unit. Here, the names of these units do not constitute a limitation to the unit itself in some cases, and for example, the acquiring unit may also be described as "a unit that acquires the data identification of the input data described above".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.