CN115525677A - Data caching method and device, computer equipment and storage medium - Google Patents

Data caching method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN115525677A
CN115525677A CN202110715856.7A CN202110715856A CN115525677A CN 115525677 A CN115525677 A CN 115525677A CN 202110715856 A CN202110715856 A CN 202110715856A CN 115525677 A CN115525677 A CN 115525677A
Authority
CN
China
Prior art keywords
data
field
rule
cache
template
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
CN202110715856.7A
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.)
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Cloud Computing Beijing 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 Tencent Cloud Computing Beijing Co Ltd filed Critical Tencent Cloud Computing Beijing Co Ltd
Priority to CN202110715856.7A priority Critical patent/CN115525677A/en
Publication of CN115525677A publication Critical patent/CN115525677A/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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation

Abstract

The embodiment of the application discloses a data caching method, a data caching device, computer equipment and a storage medium, and is applied to the technical field of computers. Wherein, the method comprises the following steps: responding to a data caching request aiming at a target service, determining service data required when the target service is executed, and acquiring at least one caching rule associated with the service data, wherein the service data required by the target service comprises at least one data type, and one data type is associated with one caching rule; obtaining cache indication information and position indication information from any cache rule; and according to the data storage position indicated by the cache indication information in any cache rule, obtaining the data to be cached under the specific data type, and sending the data to be cached under the specific data type to a cache server corresponding to the position indication information in any cache rule for caching. By the method and the device, data processing pressure of the database can be reduced, and efficiency of the client side for acquiring the service data is improved.

Description

Data caching method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data caching method and apparatus, a computer device, and a storage medium.
Background
With the development of the internet, a large amount of business data is stored in the database, and when a client provides business services for a user, business data related to the business needs to be acquired from the database. When a client acquires service data related to a service from a database through a query request, the database connection needs to be established once correspondingly for each query request, so that when a large number of clients need to acquire the service data from the database, the query response speed and the user experience are obviously reduced, the efficiency of the client acquiring the service data is reduced, and the data processing pressure of the database is increased. Therefore, how to reduce the data processing pressure of the database and improve the efficiency of the client acquiring the service data becomes an urgent problem to be solved.
Disclosure of Invention
The embodiment of the application provides a data caching method, a data caching device, computer equipment and a storage medium, which can reduce the data processing pressure of a database and improve the efficiency of a client for acquiring service data.
One aspect of the present application provides a data caching method, including:
responding to a data caching request aiming at a target service, determining service data required when the target service is executed, and acquiring at least one caching rule associated with the service data, wherein the service data required by the target service comprises at least one data type, and one data type is associated with one caching rule;
obtaining cache indication information and position indication information from any cache rule, wherein the cache indication information is used for indicating a data storage position of data to be cached under a specific data type;
and obtaining the data to be cached under a specific data type according to the data storage position indicated by the cache indication information in any cache rule, and sending the data to be cached under the specific data type to a cache server corresponding to the position indication information in any cache rule for caching.
One aspect of the present application provides a data caching apparatus, including:
the system comprises an acquisition unit, a cache management unit and a cache management unit, wherein the acquisition unit is used for responding to a data cache request aiming at a target service, determining service data required when the target service is executed, and acquiring at least one cache rule associated with the service data, wherein the service data required by the target service comprises at least one data type, and one data type is associated with one cache rule;
the obtaining unit is further configured to obtain cache indication information and location indication information from any cache rule, where the cache indication information is used to indicate a data storage location of data to be cached in a specific data type;
the obtaining unit is further configured to obtain data to be cached in a specific data type according to the data storage location indicated by the cache indication information in any cache rule;
and the sending unit is used for sending the data to be cached under the specific data type to a cache server corresponding to the position indication information in any cache rule for caching.
An aspect of the application provides a computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the method of the above-mentioned aspect of the application.
An aspect of the application provides a computer-readable storage medium having stored thereon a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of the above-mentioned aspect.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided in the various alternatives of the above aspect and the like.
In the embodiment of the application, a computer device obtains a data caching request for a target service, determines service data required when the target service is executed according to the obtained data caching request, and obtains at least one caching rule associated with the service data, the computer device obtains caching indication information and position indication information according to the caching rule associated with the service data, then the computer device obtains the service data according to the caching indication information, obtains a caching server for caching the service data according to the position indication information, and then the computer device sends the service data to the corresponding caching server for caching. In addition, when the computer device caches the service data into the cache server according to the cache rule, the computer device can store different types of data to be cached into different cache servers based on different cache rules, so that the flexibility of system cache data can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic structural diagram of a data caching system according to an embodiment of the present application;
fig. 2a is a schematic flow chart of a method for storing a cache rule according to an embodiment of the present application;
fig. 2b is a schematic flowchart of loading data to be cached to a cache server according to an embodiment of the present application;
fig. 3 is a schematic flow chart of a data caching method according to an embodiment of the present application;
fig. 4 is a schematic flow chart of a data processing method provided in an embodiment of the present application;
FIG. 5 is a schematic flow chart of a verification process performed on a rule template according to an embodiment of the present application;
FIG. 6 is a schematic flow chart diagram illustrating data processing for a rule template according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a data caching apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a data caching method, which can enable computer equipment to cache service data corresponding to services into a cache server according to a cache rule, when a client needs to acquire the service data, the service data can be directly acquired from the cache server without being acquired from a database, so that the data processing pressure of the database can be reduced, and meanwhile, the efficiency of the client in acquiring the service data can be improved. For example, for a service, the service may be a target service mentioned in this embodiment, a service data type in the service includes a type a service data, a type B service data, and a type C service data, the type a service data corresponds to a cache rule a, the type B service data corresponds to a cache rule B, and the type C service data corresponds to a cache rule C, the computer device stores the type a service data into the cache server a according to the cache rule a, caches the type B service data into the cache server B according to the cache rule B, and caches the type C service data into the cache server C according to the cache rule C, and further, when the client 1 and the client 2 need to obtain the service data under the service, if the client 1 needs to obtain the type a service data and the type B service data under the service, the client 1 may directly obtain the type a service data from the cache server a, obtain the type B service data from the cache server B, and if the client 2 needs to obtain the type a service data and the type C service data under the service, then the client 2 may directly obtain the type a service data from the cache server a cache server C. Optionally, the process of the client 1 acquiring the type a service data and the type B service data and the process of the client 2 acquiring the type a service data and the type C service data may be performed at the same time, and at this time, the concurrency and throughput of the system can be improved.
The data caching method can be applied to a data caching system as described in fig. 1, and in particular, the data caching method can be executed by a computer device in the system, wherein the system comprises: the client 10 and the technical terminal 13 may be smart phones, tablet computers, notebook computers, and the like, the technical terminal 13 may be a terminal device where a development user is located, configured to configure a caching rule, and further configured to trigger a data caching key, the client 10 may be a client for performing service execution, and it may be understood that the technical terminal 13 and the client 10 may be the same terminal device or different terminal devices, in this embodiment, the client 10 and the technical terminal 13 are different terminal devices for example, and when the client 10 and the technical terminal 13 are the same terminal device, reference may be made to this embodiment, but not limited thereto. The set of cache servers 12 may include one or more cache servers for storing the traffic data, wherein the cache servers included in the set of cache servers 12 may be, for example, the cache server 121 shown in fig. 1. Each cache server in the cache server set 12 establishes a communication connection with the client 10 and the server 11 respectively.
In the data caching system shown in fig. 1, a development user configures a caching rule at a technical terminal 13, the technical terminal 13 sends the configured caching rule to a computer device 11, and the computer device 11 stores the caching rule in a database after receiving the caching rule. Referring to fig. 2a, in fig. 2a, after the computer device 11 receives the cache rule configured by the development user and input by the technical terminal 13, the computer device 11 verifies the cache rule, when the computer device 11 passes the verification of the cache rule, the computer device 11 performs data processing on the cache rule, and after the computer device 11 performs data processing on the cache rule, the computer device 11 stores the cache rule in the database, so that when the next execution stores the service data in the cache server, the cache rule can be reused, and the cache rule is made persistent. When the computer device 11 obtains a data caching request for a target service, a cache executor in the computer device 11 executes a process of loading data to be cached to a cache server, where the process of executing the data to be cached to the cache server by the cache executor in the computer device 11 is shown in fig. 2b, the computer device 11 traverses a cache rule in a database to obtain a cache rule for the target service, the computer device 11 executes a data query statement in the cache rule corresponding to the target service, if the data query statement fails to be executed, the computer device 11 finishes executing the process of loading the data to be cached to the cache server, if the data query statement is successfully executed, the computer device 11 obtains service data corresponding to the target service in the database, then the computer device 11 caches the service data corresponding to the target service to a cache server in the server set 12, and when the client 10 needs to obtain the service data corresponding to the target service, the client 10 may directly obtain the service data corresponding to the target service in the cache server set 12. In an embodiment, the client, the computer device, and the cache server in the cache server set may be node devices in a blockchain network, and then the client, the computer device, and each cache server in the cache server set may perform data transmission based on the blockchain network, and it can be understood that data security during data transmission between the client, the computer device, and each cache server may be ensured based on a data transmission mode of the blockchain network. The Blockchain (Blockchain) is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. The block chain, which is essentially a decentralized database, is a string of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, which is used for verifying the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
Referring to fig. 3, fig. 3 is a schematic flowchart of a data caching method according to an embodiment of the present application, where the data caching method may be executed by the computer device, and the computer device may be a server or a terminal device. The server and the cache server in the cache server set 12 may be an independent physical server, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and an artificial intelligence platform, which is not limited in the embodiment of the present application. As shown in fig. 3, the method may include:
s301, responding to the data caching request aiming at the target service, determining the service data required when the target service is executed, and acquiring at least one caching rule associated with the service data.
In an embodiment, the computer device determines a service execution time of the target service, and determines that a data caching request for the target service is detected when a time difference between the service execution time and a current time is within a preset time range, that is, the computer device may set a time to periodically cache service data corresponding to the target service in the caching server. For example, the target service is a shopping activity on the shopping software, the service execution time is a, the current time is B, and the preset time range is set to be two days, so that when the time difference between the service execution time a and the current time B is less than two days, the computer device determines that a data caching request for the shopping activity is detected. Or when detecting the operation of triggering the data cache key by the development user, the computer device determines to detect the data cache request for the target service. For example, when the development user determines that business data corresponding to a shopping activity is to be cached in the cache server, the development user may click a data cache key in an interface of the technical terminal, and after the developer clicks the data cache key in the interface of the technical terminal, the computer device determines that a data cache request for the shopping activity is detected.
The service data required by the target service comprises service data under at least one data type, and the service data under one data type is associated with one cache rule. For example, the target service is a user authentication service, and the service data of the user authentication service includes at least one or more of the following: the service data of the user name type, the service data of the first identity code type, the service data of the second identity code type and the like, wherein the first identity code type refers to an identity card number, and the second identity code type can be a telephone number, a social software account and the like. The business data of the user name type is associated with a cache rule, the data of the identity card number type is associated with a cache rule, and the business data of the telephone number type is associated with a cache rule. Optionally, when the computer device obtains multiple cache rules associated with the service data, the multiple cache rules associated with the service data may be obtained at the same time, so as to improve throughput of the system.
In one embodiment, the cache rule records a rule for caching the service data of the target service, the development user can configure the cache rule at the technical terminal, the technical terminal sends the cache rule configured by the development user to the computer device, and the computer device verifies the field data in the cache rule after receiving the cache rule sent by the technical terminal. After the field data in any cache rule is verified by the computer device, if a target field exists in any cache rule and the field data corresponding to the target field is empty, the computer device processes the field data corresponding to the target field in any cache rule according to a default value. And then the computer equipment stores the caching rule subjected to default value processing into a database. Alternatively, the form of the caching rule in the database may be a form of a rule template, a configuration file, a JS (a lightweight, interpreted, or just-in-time programming language with function precedence) Object Notation (JavaScript Object Notation), an XML (extensible markup language), or the like.
S302, cache indication information and position indication information are obtained from any cache rule.
Wherein, the cache indication information recorded in the cache rule is used for indicating: the data storage method comprises the steps of storing data to be cached in a database in a data table mode, storing the data to be cached in the same column of the data table in the same data type, storing the data to be cached in the database in a key-value mode, and storing the data to be cached in the same data type in the database and corresponding to the same key value after storing the data to be cached in the same data type in the database, namely, the same key value corresponds to the same column of the data table. The cache indication information recorded in the cache rule includes a data type identifier, and the data type identifier at least includes: the key values corresponding to the data to be cached of the same data type after being stored in the database may be understood that the data type of the data to be cached pointed by the key values included in the cache indication information recorded in the cache rule is the specific data type. In addition, the data type identification may further include: the key prefix is cached and is used for naming the key value. The location indication information may be used to indicate an address of a cache server that caches data to be cached in a specific data type, and by the location indication information, the computer device may be located to the cache server to establish a communication connection with the cache server, and the location indication information may be, for example, an address of the cache server, a username of the cache server, and a password of the cache server.
Optionally, when the computer device obtains multiple cache rules associated with the service data, the computer device may simultaneously obtain cache indication information in the multiple cache rules associated with the service data, and simultaneously obtain location indication information in the multiple cache rules associated with the service data, so that throughput of the system can be improved.
And S303, obtaining the data to be cached in a specific data type according to the data storage position indicated by the cache indication information in any cache rule, and sending the data to be cached in the specific data type to a cache server corresponding to the position indication information in any cache rule for caching.
In one embodiment, the data to be cached in the specific data type is stored in the database, the computer device determines the required target data type according to the data type identifier included in the cache indication information in any cache rule, and uses a data query statement, the computer device locates the target column in which the target data type is located from the data table, and the computer device uses the data query statement to obtain all data in the target column as the data to be cached in the specific data type. The data Query statement may be Structured Query Language (SQL), the data to be cached in a specific data type may also be stored in other places where the electronic file can be stored, and the data Query statement may be a statement that can perform data Query in other places where the electronic file is stored. Optionally, the computer device simply processes the data to be cached of the specific data type obtained by querying, including null value, default value and the like, the computer device determines a cache server for caching the data to be cached of the specific data type according to the position indication information in any cache rule, the computer device connects the database and the cache server, and after the connection is completed, the computer device stores the data to be cached of the specific data type in the cache server. It should be understood that different caching servers may be connected in different ways, as may the way data is cached.
In one embodiment, the computer device obtains multiple types of data to be cached according to multiple caching rules, and the computer device caches the obtained multiple types of data to be cached simultaneously to the caching computer devices corresponding to the multiple types of data to be cached respectively according to the multiple caching rules, so that the throughput of the system can be improved. For example, the computer device obtains data to be cached of type a, data to be cached of type B, and data to be cached of type C, where the data to be cached of type a corresponds to the cache server a, the data to be cached of type B corresponds to the cache server B, and the data to be cached of type C corresponds to the cache server C, and when the computer device caches the data to be cached of type a to the cache server a, the computer device caches the data to be cached of type B to the cache server B, and caches the data to be cached of type C to the cache server C.
In the embodiment of the application, a computer device obtains a data caching request for a target service, determines service data required when the target service is executed according to the obtained data caching request, and obtains at least one caching rule associated with the service data, the computer device obtains caching indication information and position indication information according to the caching rule associated with the service data, then the computer device obtains the service data according to the caching indication information, obtains a caching server for caching the service data according to the position indication information, and then the computer device sends the service data to the caching server corresponding to the service data for caching. In addition, when the computer device caches the service data into the cache server according to the cache rule, the computer device can store different types of data to be cached into different cache servers based on different cache rules, so that the flexibility of the system cache data can be improved.
In the embodiments of the present application, a detailed description is provided of a manner of storing the caching rule in the database, and when the caching rule is stored in the database, the caching rule may also be executed by the computer device, where the computer device may be a server or a terminal device. Referring to fig. 4, fig. 4 is a schematic flow chart of a data processing method provided in the embodiment of the present application, and mainly describes in detail a process of storing a cache rule in a database in a form of a rule template, where reference may be made to the embodiment of the present application when the cache rule is stored in other forms, such as an XML form, a configuration file, and the like, in the database. As shown in fig. 4, the method may include:
s401, field data corresponding to each template field in any rule template is obtained, and the field data is verified to obtain a data verification result corresponding to each field data.
In one embodiment, the process of verifying the rule template by the computer device can be seen in fig. 5, and as shown in fig. 5, the process of verifying the rule template by the computer device includes steps s11 to s15.
And s11, the computer equipment acquires the rule template input by the development user.
In one embodiment, a development user inputs a rule template at a technical terminal, the technical terminal sends the rule template input by the development user to a computer device, and after the computer device receives the rule template sent by the terminal, the computer device obtains field data corresponding to each template field in any rule template and performs verification processing on the field data to obtain a data verification result corresponding to each field data.
For example, please refer to table 1, some template fields in the rule template are shown in table 1, and the template fields in the rule template shown in table 1 include a name field, preheating time, a data query statement, a cache key prefix, data expiration time, a cache server address, a cache server user name, and a cache server password. The field data corresponding to the name field is used for indicating the template name of any rule template, and the field data corresponding to the preheating time is used for indicating the time for sending the data to the cache server for caching; the field data corresponding to the data query statement is used for querying business data associated with any rule template in the database; the field data corresponding to the cache key is a key value and is used for indicating the data storage position of the business data in the database; the field data corresponding to the prefix of the cache key is the name of the cache key; the field data corresponding to the cache data expiration time is used for indicating how long the service data can be stored in the cache server, and the cache data expiration time is null, which indicates that the service data is never expired in the cache server, meaning that the service data can be permanently stored in the cache server; the field data corresponding to the address of the cache server is used for indicating the address of the cache server for storing the service data; and the field data corresponding to the cache server user name and the field data corresponding to the cache server password are used for connecting the cache server corresponding to the cache server address. Table 1 mainly provides some template fields, where the template fields are general template fields of a rule template, and the name fields must be unique, and the template fields may also be expanded by a user according to the needs of a development user, which is not limited in the embodiment of the present application.
TABLE 1
Name Name field
Cron Preheating time
Sql Data query statement
Key Caching keys
Prefix Caching key prefixes
Expire Data expiration time
Host Caching server addresses
Username Caching server user names
Password Caching server passwords
And s12, the computer device judges whether the rule template corresponding to the name field exists in the database according to the name field in the rule template. If the rule template exists, the computer device ends the process of checking the rule template, and if the rule template does not exist, the computer device executes the step s13.
In one embodiment, the template field of the rule template is multiple and at least comprises a name field, and each template field corresponds to field data. When the computer device checks the field data in any rule template, the computer device obtains the field data corresponding to the name field included in any rule template, and the field data corresponding to the name field is used for indicating the template name of any rule template. If no other rule template with the same template name as any rule template exists in the database, the computer equipment carries out verification processing on field data corresponding to each template field except the name field in any rule template to obtain a data verification result corresponding to each field data. And if other rule templates with the same template name as any rule template exist in the database, the computer equipment performs exception throwing processing.
s13, the computer device checks field data corresponding to the template field in the rule template, where the template field in the rule template may include a name field, a preheating time, a cache key prefix, and a cache server address as shown in fig. 5.
In one embodiment, when the computer device performs a verification process on field data corresponding to each template field except a name field in any rule template, the computer device determines a first type template field and a second type template field in any rule template, wherein the first type template field refers to a field, which must be set by a development user, of the corresponding field data and can be understood as a necessary field, and the second type template field refers to a field, which does not have to be set by the development user and can be understood as a non-necessary field. The computer equipment carries out regular verification on the field data of the first type of template field to obtain a data verification result of the field data corresponding to the first type of template field, the regular verification is a mode of verifying the data through a regular expression, the regular expression describes a character string matching mode and can be used for checking whether a character string contains a certain substring, replacing the matched substring or taking out the substring meeting a certain condition from the certain substring, and the like, namely the computer equipment can verify the character string corresponding to the field data through the regular verification, so that the verification result of the field data is obtained. And the computer device performs data verification processing on the field data of the second type template field by adopting a reflection mechanism to obtain a data verification result of the field data corresponding to the second type template field, wherein the reflection mechanism is that in an operating state, all attributes and methods of any type can be known by the reflection mechanism, that is, the computer device can know the field data corresponding to the second type template field according to the second type template field by the reflection mechanism, and when a development user configures the corresponding field data for the second type template field in the rule template, the computer device can verify the field data corresponding to the second type template field configured by the development user by using the field data corresponding to the second type template field acquired by the reflection mechanism, and judge whether the field data in the second type template field configured by the development user is reasonable.
In one embodiment, the computer device needs to check the field data strictly to determine whether the western field data is reasonable, which may include determining whether the field data corresponding to the preheat time is reasonable (e.g., determining whether the preheat time is time type data and whether the time is correct and reasonable), determining whether the field data corresponding to the cache key is reasonable (e.g., whether the cache key is too long), determining whether the field data corresponding to the expiration time is reasonable (e.g., whether the expiration time is too long), and so on.
s14, the computer device determines whether the field data check is passed, and if the field data check corresponding to the template field in the rule template is passed, the computer device executes step s15.
And s15, the computer device performs data processing on the rule template, and after the computer device performs data processing on the rule template, the computer device ends the flow of processing the rule template input by the development user.
The data processing procedure of the rule template by the computer device can be described in detail in S402.
S402, according to the data verification result of each field data, determining the verification result aiming at any rule template, and storing any rule template into the database when any rule template passes the verification.
In one embodiment, for any rule template, when the data verification result of each field data in any rule template passes, the computer device determines that the data verification result of any rule template is pass, and when the data verification result of the field data in any rule template does not pass, the computer device determines that the data verification result of any rule template is not pass.
In one embodiment, if the computer device checks the field data corresponding to the template field in the rule template, the computer device performs data processing on the rule template. The flow of data processing of the rule template by the computer device can be seen in fig. 6, and as shown in fig. 6, the data processing of the rule template by the computer device includes steps s21 to s24.
s21, the computer device performs default value processing on the target field without a value in the rule template.
In one embodiment, after the computer device passes the field data check in any rule template, if a target field exists in any rule template and the field data corresponding to the target field is null, the computer device performs default value processing on the field data corresponding to the target field in any rule template, and adopts default data as the field data of the target field.
And s22, the computer device judges whether the connection with the cache server is successful, if the connection with the cache server is successful, the step s23 is executed, and if the connection with the cache server is failed, the step of executing the data processing flow of the rule template is finished.
In an embodiment, after the computer device performs default value processing on field data corresponding to a target field in any rule template, the computer device may connect, according to the position indication information in any rule template, to a cache server corresponding to the position indication information.
s23, the computer device generates a verifier.
In one embodiment, after the computer device obtains field data with default data as a target field, the computer device performs a regular expression for data verification on the field data in any rule template. And the computer equipment generates a corresponding checker according to the regular expression.
And s24, the computer equipment stores the checker in a cache and stores the rule template in a database.
In one embodiment, the computer device stores the checker in the cache, so that after the any rule template is acquired, the computer device performs data verification processing on the field data in the any rule template by using the checker, so that the checker can be reused when the field data of the any rule template is verified next time. And simultaneously, the computer equipment stores any rule template into the database, so that any rule template can be reused when the computer equipment caches the service data.
In one embodiment, the target service is an identity authentication service, the service data corresponding to the identity authentication service includes service data of a user name type, service data of an identity card number type and service data of a telephone number type, a cache rule associated with the identity authentication service is configured in the technical terminal in advance by a development user, the cache rule associated with the identity authentication service is sent to the computer equipment by the technical terminal, and after the computer equipment receives the cache rule associated with the identity authentication service, the cache rule associated with the identity authentication service is stored in the database by the computer equipment. When the computer equipment receives a data caching request related to the identity authentication service, the computer equipment determines that the required service data are user name type service data, identity card number type service data and telephone number type service data according to the data caching request, the computer equipment can traverse the caching rules in the database to obtain a caching rule related to the user name type service data, a caching rule related to the identity card number type service data and a caching rule related to the telephone number type service data, the caching rule related to the user name type service data indicates that the user name type service data are cached in the caching server A, the caching rule related to the identity card number type service data indicates that the identity card number type service data are cached in the caching server B, the caching rule related to the telephone number type service data indicates that the telephone number type service data are cached in the caching server C, the computer equipment obtains the user name type service data in the caching database according to the data caching rule related to the identity card number type service data, the computer equipment stores the obtained user name type service data in the caching rule related to the identity card number type service data in the caching server B, and the user name type service data are obtained according to the caching rule related to the user name type service data stored in the caching server A, the caching rule related to the user name type service data. And the computer equipment caches the acquired service data of the telephone number type in a cache server C. When a user needs to perform identity authentication, if the user A inputs a user name and a telephone number at the client, the client can acquire the user name and the telephone number from the cache server A and the cache server B, and the client compares the acquired user name and telephone number with the user name and telephone number input by the user A to complete identity authentication of the user A; if the user B inputs the user name and the identity card number at the client, the client can acquire the user name and the identity card number in the cache server A and the cache server C, and the client compares the acquired user name and the identity card number with the user name and the identity card number input by the user B to complete the identity authentication of the user B. Due to the fact that the service data acquired by the client from the cache servers may be different for different users, the client can dynamically select to acquire different types of service data from different cache servers for different users, and accordingly flexibility of the system can be improved.
In the embodiment of the application, the computer device can obtain the cache rule configured by the development user, when the computer device obtains the data cache request for the target service, the service data is cached in the cache server according to the cache rule configured by the development user, and the cache rule configured by the development user can be modified according to the requirement of the development user, so that the flexibility of the system for caching the data can be improved when the system caches the service data. When the client needs to acquire the service data, the service data can be directly acquired from the cache server without being acquired from the database, so that the data processing pressure of the database can be reduced, and the efficiency of the client for acquiring the service data can be improved.
Based on the data caching method, the embodiment of the application provides a data caching device. Referring to fig. 7, fig. 7 is a schematic structural diagram of a data caching apparatus according to an embodiment of the present disclosure. The data caching apparatus described in fig. 7 may operate as follows:
an obtaining unit 701, configured to determine, in response to a data caching request for a target service, service data required when the target service is executed, and obtain at least one caching rule associated with the service data, where the service data required by the target service includes at least one data type, and one data type is associated with one caching rule;
the obtaining unit 701 is further configured to obtain cache indication information and location indication information from any cache rule, where the cache indication information is used to indicate a data storage location of data to be cached in a specific data type;
the obtaining unit 701 is further configured to obtain data to be cached in a specific data type according to the data storage location indicated by the cache indication information in any cache rule;
a sending unit 702, configured to send the data to be cached in the specific data type to a cache server corresponding to the location indication information in any cache rule for caching.
In one embodiment, at least one caching rule associated with the business data is obtained from a database, the caching rule comprises rule templates, and any rule template comprises at least one template field; the obtaining unit 701 is further configured to obtain field data corresponding to each template field in any rule template, and perform verification processing on the field data to obtain a data verification result corresponding to each field data; the obtaining unit 701 is further configured to determine a verification result for any rule template according to the data verification result of each field data, and store any rule template in the database when any rule template passes verification.
In one embodiment, the rule template has a plurality of corresponding template fields, and at least comprises a name field, and each template field corresponds to field data; the obtaining unit 701 is further configured to obtain field data corresponding to a name field included in any rule template, where the field data corresponding to the name field is used to indicate a template name of any rule template; and if no other rule template with the same template name as any rule template exists in the database, performing verification processing on field data corresponding to each template field except the name field in any rule template to obtain a data verification result corresponding to each field data.
In an embodiment, the obtaining unit 701 is further configured to determine a first type template field and a second type template field from any rule template, where the first type template field refers to a field whose corresponding field data must be set by a user, and the second type template field refers to a field that is not necessarily set by the user; the obtaining unit 701 is further configured to perform regular verification on the field data of the first-class template field to obtain a data verification result of the field data corresponding to the first-class template field; and carrying out data verification processing on the field data of the second type template field by adopting a reflection mechanism to obtain a data verification result of the field data corresponding to the second type template field.
In one embodiment, if a target field exists in any rule template and field data corresponding to the target field is null, default data is adopted as the field data of the target field; the acquiring unit 701 is further configured to acquire a regular expression for performing data verification on field data in any rule template after the field data using default data as a target field is acquired; and generating a corresponding checker according to the regular expression, and storing the checker in a cache so as to perform data verification processing on field data in any rule template by using the checker after any rule template is obtained.
In one embodiment, the data to be cached is stored in the database in the form of a data table, and the data to be cached under the same data type is stored in the same column of the data table; the cache indication information includes: data type identification; the obtaining unit 701 is further configured to determine a required target data type according to a data type identifier included in the cache indication information in any cache rule, and locate, by using a data query statement, a target column in which the target data type is located from a data table; the obtaining unit 701 is further configured to obtain all data in the target column as data to be cached in the specific data type by using a data query statement.
In an embodiment, the obtaining unit 701 is further configured to determine a service execution time of the target service, and determine that a data caching request for the target service is detected when a time difference between the service execution time and a current time is within a preset time range; or when detecting the operation of triggering the data cache key by the development user, determining that the data cache request aiming at the target service is detected.
In the embodiment of the application, a server acquires a cache rule configured by a user, performs data verification processing on the cache rule configured by the user, and then stores the cache rule in a database, when the server acquires a data cache request for a target service, the server determines service data required when the target service is executed according to the acquired data cache request, and acquires at least one cache rule associated with the service data in the database, the server acquires cache indication information and position indication information according to the cache rule associated with the service data, then the server acquires the service data according to the cache indication information, and acquires a cache server for caching the service data according to the position indication information, and then the server sends the service data to the cache server corresponding to the service data for caching. Therefore, the method provided by the application can obtain the caching rules configured by the user, different caching rules correspond to different types of data, so that when the server caches the service data according to the caching rules, the caching rules are different for the different types of data, the flexibility of the system caching the data can be improved, and when the server caches the data to the caching server according to the caching rules, the server can cache the service data in the same service scene to the caching server at the same time, and the concurrency and throughput of the system can be improved.
Based on the embodiments of the data caching method and the data caching device, the embodiments of the present application provide a computer device, which may be a server. Referring to fig. 8, fig. 8 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure. The computer device shown in fig. 8 may include at least a processor 801, an input interface 802, an output interface 803, and a memory 804. The processor 801, the input interface 802, the output interface 803, and the memory 804 may be connected by a bus or other means.
The memory 804 may be stored in a memory of a computer device, the storage 804 being for storing a computer program comprising program instructions, the processor 801 being for executing the program instructions stored by the memory 804. The processor 801 (or CPU) is a computing core and a control core of a computer device, and is adapted to implement one or more instructions for implementing the steps of the corresponding methods in fig. 3 and 4.
In one embodiment, the processor 801 is configured to call the program instructions for performing:
responding to a data caching request aiming at a target service, determining service data required when the target service is executed, and acquiring at least one caching rule associated with the service data, wherein the service data required by the target service comprises at least one data type, and one data type is associated with one caching rule;
obtaining cache indication information and position indication information from any cache rule, wherein the cache indication information is used for indicating the data storage position of data to be cached under a specific data type;
obtaining data to be cached under a specific data type according to a data storage position indicated by cache indication information in any cache rule;
and sending the data to be cached under the specific data type to a cache server corresponding to the position indication information in any cache rule for caching.
In one embodiment, at least one caching rule associated with the business data is obtained from a database, the caching rule includes rule templates, and any rule template includes at least one template field; the processor 801 is configured to invoke the program instructions for performing:
acquiring field data corresponding to each template field in any rule template, and verifying the field data to obtain a data verification result corresponding to each field data;
and determining a verification result aiming at any rule template according to the data verification result of each field data, and storing any rule template into the database when any rule template passes verification.
In one embodiment, the rule template has a plurality of corresponding template fields, and at least includes a name field, and each template field corresponds to a field data; the processor 801 is configured to invoke the program instructions for performing:
acquiring field data corresponding to a name field included in any rule template, wherein the field data corresponding to the name field is used for indicating the template name of any rule template;
and if no other rule template with the same template name as any rule template exists in the database, verifying the field data corresponding to each template field except the name field in any rule template to obtain a data verification result corresponding to each field data.
In one embodiment, the processor 801 is configured to call the program instructions for performing:
determining a first type template field and a second type template field from any rule template, wherein the first type template field refers to a field of which corresponding field data must be set by a user, and the second type template field refers to a field which is not necessarily set by the user;
performing regular verification on field data of the first type template field to obtain a data verification result of the field data corresponding to the first type template field; and carrying out data verification processing on the field data of the second type template field by adopting a reflection mechanism to obtain a data verification result of the field data corresponding to the second type template field.
In one embodiment, if a target field exists in any rule template and field data corresponding to the target field is null, default data is adopted as the field data of the target field; the processor 801 is configured to invoke the program instructions for performing:
after acquiring field data with default data as a target field, carrying out data verification on the field data in any rule template;
and generating a corresponding checker according to the regular expression, and storing the checker in a cache so as to perform data verification processing on field data in any rule template by using the checker after any rule template is obtained.
In one embodiment, the data to be cached is stored in the database in the form of a data table, and the data to be cached under the same data type is stored in the same column of the data table; the cache indication information includes: data type identification; the processor 801 is configured to invoke the program instructions for performing:
determining a required target data type according to a data type identifier included in cache indication information in any cache rule, and positioning a target column where the target data type is located from a data table by adopting a data query statement;
and acquiring all data in the target column as data to be cached under a specific data type by adopting a data query statement.
In one embodiment, the processor 801 is configured to call the program instructions for performing:
determining the service execution time of the target service, and determining to detect a data cache request aiming at the target service when the time difference between the service execution time and the current time is within a preset time range;
or when detecting the operation of the development user for triggering the data cache key, determining that the data cache request aiming at the target service is detected.
It should be understood that the computer device 800 described in this embodiment of the present application may perform the description of the data caching method in the embodiment corresponding to fig. 3 and fig. 4, and may also perform the description of the data caching apparatus in the embodiment corresponding to fig. 7, which is not described herein again. In addition, the beneficial effects of the same method are not described in detail.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where the computer program executed by the aforementioned data caching apparatus is stored in the computer-readable storage medium, and the computer program includes program instructions, and when the processor executes the program instructions, the description of the data caching method in the embodiment corresponding to fig. 3 and fig. 4 can be performed, so that details are not repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in the embodiments of the computer storage medium referred to in the present application, reference is made to the description of the embodiments of the method of the present application.
As an example, the program instructions described above may be executed on one computer device, or on multiple computer devices located at one site, or on multiple computer devices distributed over multiple sites and interconnected by a communication network, which may constitute a blockchain network.
Embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method embodiment as shown in fig. 3 or fig. 4. The computer-readable storage medium may be the data caching apparatus provided in any of the foregoing embodiments or an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Memory Card (SMC), a Secure Digital (SD) card, a flash card (flash card), and the like, provided on the computer device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the computer device. The computer-readable storage medium is used for storing the computer program and other programs and data required by the computer device. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
The terms "first," "second," and the like in the description and in the claims and drawings of the embodiments of the present application are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or apparatus that comprises a list of steps or elements is not limited to the listed steps or modules, but may alternatively include other steps or modules not listed or inherent to such process, method, apparatus, product, or apparatus.
Those of ordinary skill in the art will appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the components and steps of the various examples have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The method and the related apparatus provided by the embodiments of the present application are described with reference to the flowchart and/or the structural diagram of the method provided by the embodiments of the present application, and specifically, each flow and/or block of the flowchart and/or the structural diagram of the method, and the combination of the flows and/or blocks in the flowchart and/or the block diagram, may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block or blocks of the block diagram. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block or blocks.
While the present invention has been described with reference to particular embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A method for caching data, the method comprising:
responding to a data caching request aiming at a target service, determining service data required when the target service is executed, and acquiring at least one caching rule associated with the service data, wherein the service data required by the target service comprises service data under at least one data type, and the service data under one data type is associated with one caching rule;
obtaining cache indication information and position indication information from any cache rule, wherein the cache indication information is used for indicating the data storage position of data to be cached under a specific data type;
and obtaining the data to be cached under the specific data type according to the data storage position indicated by the cache indication information in any cache rule, and sending the data to be cached under the specific data type to a cache server corresponding to the position indication information in any cache rule for caching.
2. The method of claim 1, wherein the at least one caching rule associated with the business data is obtained from a database, the caching rule comprising rule templates, any rule template comprising at least one template field; the generation mode of any rule template in the database comprises the following steps:
acquiring field data corresponding to each template field in any rule template, and verifying the field data to obtain a data verification result corresponding to each field data;
and determining a verification result aiming at any rule template according to the data verification result of each field data, and storing any rule template into the database when the rule template passes the verification.
3. The method of claim 2, wherein the rule template corresponds to a plurality of template fields and includes at least a name field, each template field corresponding to a field data; the verifying the field data to obtain a data verification result corresponding to each field data includes:
acquiring field data corresponding to a name field included in any rule template, wherein the field data corresponding to the name field is used for indicating the template name of any rule template;
and if no other rule template with the same template name as any rule template exists in the database, performing verification processing on field data corresponding to each template field except the name field in any rule template to obtain a data verification result corresponding to each field data.
4. The method of claim 3, wherein the performing the verification process on the field data corresponding to each template field except the name field in any rule template to obtain the data verification result corresponding to each field data comprises:
determining a first type template field and a second type template field from any rule template, wherein the first type template field refers to a field of which corresponding field data must be set by a development user, and the second type template field refers to a field which is not necessarily set by the development user;
performing regular verification on the field data of the first type template field to obtain a data verification result of the field data corresponding to the first type template field; and carrying out data verification processing on the field data of the second type template field by adopting a reflection mechanism to obtain a data verification result of the field data corresponding to the second type template field.
5. The method of claim 2, wherein the method further comprises:
if a target field exists in any rule template and field data corresponding to the target field is empty, adopting default data as the field data of the target field;
after the default data is used as field data of the target field, a regular expression for carrying out data verification on the field data in any rule template is obtained;
and generating a corresponding checker according to the regular expression, and storing the checker in a cache so as to perform data verification processing on field data in any rule template by using the checker after acquiring any rule template.
6. The method of claim 1, wherein the data to be cached is stored in a database in the form of a data table, and the data to be cached under the same data type is stored in the same column of the data table; the cache indication information includes: data type identification;
the obtaining the data to be cached in the specific data type according to the data storage location indicated by the cache indication information in any cache rule includes:
determining a required target data type according to a data type identifier included in the cache indication information in any cache rule, and positioning a target column where the target data type is located from the data table by adopting a data query statement;
and acquiring all data in the target column as the data to be cached under the specific data type by adopting the data query statement.
7. The method of any one of claims 1-6, further comprising:
determining the service execution time of the target service, and determining that the data cache request aiming at the target service is detected when the time difference between the service execution time and the current time is within a preset time range; alternatively, the first and second electrodes may be,
and when detecting that a development user triggers a data cache key, determining to detect the data cache request aiming at the target service.
8. A data caching apparatus, comprising:
an obtaining unit, configured to determine, in response to a data caching request for a target service, service data required when the target service is executed, and obtain at least one caching rule associated with the service data, where the service data required by the target service includes at least one data type, and one data type is associated with one caching rule;
the acquisition unit is further used for acquiring cache indication information and position indication information from any cache rule, wherein the cache indication information is used for indicating the data storage position of the data to be cached under a specific data type;
the obtaining unit is further configured to obtain data to be cached in the specific data type according to the data storage location indicated by the cache indication information in the any cache rule;
and the sending unit is used for sending the data to be cached under the specific data type to a cache server corresponding to the position indication information in any cache rule for caching.
9. A computer arrangement comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to carry out the steps of the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program adapted to be loaded by a processor and to perform the method of any of claims 1-7.
CN202110715856.7A 2021-06-25 2021-06-25 Data caching method and device, computer equipment and storage medium Pending CN115525677A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110715856.7A CN115525677A (en) 2021-06-25 2021-06-25 Data caching method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110715856.7A CN115525677A (en) 2021-06-25 2021-06-25 Data caching method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115525677A true CN115525677A (en) 2022-12-27

Family

ID=84694527

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110715856.7A Pending CN115525677A (en) 2021-06-25 2021-06-25 Data caching method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115525677A (en)

Similar Documents

Publication Publication Date Title
CN112446785B (en) Cross-chain transaction method, system, device, equipment and storage medium
US9230066B1 (en) Assessing risk for third-party data collectors
US20130283362A1 (en) Authenticating user through web extension using token based authentication scheme
CN111092899B (en) Information acquisition method, device, equipment and medium
US20140298034A1 (en) Data authenticity assurance method, management computer, and storage medium
CN110365483B (en) Cloud platform authentication method, client, middleware and system
CN111639327A (en) Authentication method and device for open platform
JP2011215753A (en) Authentication system and authentication method
CN111290742A (en) Parameter verification method and device, electronic equipment and readable storage medium
CN112491776B (en) Security authentication method and related equipment
CN108259457B (en) WEB authentication method and device
CN110708335A (en) Access authentication method and device and terminal equipment
CN111314172A (en) Data processing method, device and equipment based on block chain and storage medium
CN112118269A (en) Identity authentication method, system, computing equipment and readable storage medium
WO2023093500A1 (en) Access verification method and apparatus
CN115695012A (en) Login request processing method and device, electronic equipment and storage medium
JP7099198B2 (en) Management equipment, management systems and programs
GB2567715A (en) Authentication system, method and program
CN112948499A (en) Information acquisition method and device, electronic equipment and storage medium
CN111835504B (en) Identification code generation method and server
CN109348472B (en) OTA (over the air) upgrading method and system based on single-point pushing
KR101745919B1 (en) User authentication method and system using software-based HSM without password exposure
CN113472781B (en) Service acquisition method, server and computer readable storage medium
CN112597118B (en) Shared file adding method and device
CN115525677A (en) Data caching method and device, computer equipment and storage medium

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