Disclosure of Invention
The invention provides a device information management method and device, electronic equipment and a storage medium, which are used for solving the technical problems that data cannot be cleaned in time and the data cleaning timeliness is poor in the prior art.
The invention provides an equipment information management method, which is applied to an interface server, wherein the interface server is connected with a client and a database; the method comprises the following steps:
receiving a report request of preset equipment sent by the client; the reporting request carries equipment information;
carrying out validity check on the equipment information;
when the verification is passed, acquiring a storage period of the equipment;
acquiring weighted packet information corresponding to the storage period;
calculating the survival validity period of the equipment information according to the weighted packet information and the storage period;
storing the equipment information to the database according to the survival validity period; and the database is used for carrying out expiration marking and data cleaning on the equipment information according to the survival validity period.
Optionally, the device information includes user login information, a device code, operating system information, client application version information, a network mode, an access application ID, and a check token.
Optionally, the step of obtaining a storage period of the device includes:
sending the device code to the database;
and receiving the storage period of the equipment returned by the database based on the equipment code.
Optionally, the interface server is further connected with a preset configuration center; the step of obtaining the weighted packet information corresponding to the storage period includes:
sending a query request to the configuration center;
and receiving the weighted packet information corresponding to the storage period returned by the configuration center based on the query request.
Optionally, the step of storing the device information to the database according to the validity period of survival includes:
generating a reporting log of the equipment information;
and sending the equipment information and the report log to the database according to the survival validity period.
The embodiment of the invention also provides an equipment information management device which is applied to an interface server, wherein the interface server is connected with the client and the database; the device comprises:
a report request receiving module, configured to receive a report request of a preset device sent by the client; the reporting request carries equipment information;
the validity checking module is used for checking the validity of the equipment information;
the storage period acquisition module is used for acquiring the storage period of the equipment after the verification is passed;
the weighted packet information acquisition module is used for acquiring weighted packet information corresponding to the storage period;
a validity-to-live acquiring module, configured to calculate a validity-to-live of the device information according to the weighted packet information and the storage period;
the storage module is used for storing the equipment information to the database according to the survival validity period; and the database is used for carrying out expiration marking and data cleaning on the equipment information according to the survival validity period.
Optionally, the device information includes user login information, a device code, operating system information, client application version information, a network mode, an access application ID, and a check token.
Optionally, the storage period obtaining module includes:
the equipment code sending submodule is used for sending the equipment code to the database;
and the storage period receiving submodule is used for receiving the storage period of the equipment returned by the database based on the equipment code.
The invention also provides an electronic device comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute the device information management method according to an instruction in the program code.
The present invention also provides a computer-readable storage medium for storing a program code for executing the device information management method as described in any one of the above.
According to the technical scheme, the invention has the following advantages: the invention discloses a device information management method, which comprises the steps of receiving a report request of preset devices sent by a client; the reporting request carries equipment information; verifying the validity of the equipment information; when the verification is passed, acquiring a storage period of the equipment; acquiring weighted packet information corresponding to a storage period; calculating the survival validity period of the equipment information according to the weighted packet information; storing the equipment information to a database according to the survival validity period; and the database is used for carrying out expiration marking and data cleaning on the equipment information according to the survival validity period.
According to the invention, the expiration marking and data cleaning are carried out on the equipment information stored in the database by calculating the survival validity period of the equipment information so as to realize the timely cleaning of the equipment information, the timeliness is strong, and the occurrence of the data redundancy phenomenon in the database can be reduced.
Detailed Description
The embodiment of the invention provides a device information management method and device, electronic equipment and a storage medium, and aims to solve the technical problems that data cannot be cleaned in time and data cleaning timeliness is poor in the prior art.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, 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 invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for managing device information according to an embodiment of the present invention.
The device information management method provided by the invention specifically comprises the following steps:
step 101, receiving a report request of preset equipment sent by a client; the reporting request carries equipment information;
in the embodiment of the invention, an interface Application Program (API) server is connected with a client and can receive an equipment information reporting request sent by a client APP, wherein the equipment information records the label information of equipment and the related information of an uploading user.
102, verifying the validity of the equipment information;
after the API server side obtains the equipment information, validity verification can be carried out on the basis of the equipment information, and whether the equipment information accords with an uploading rule or not is verified.
103, acquiring a storage period of the equipment after the verification is passed;
after the device information is verified, the API server may obtain the configuration information pre-configured in the database by the device, and obtain a storage period of the device from the configuration information, where the storage period may be used to define a storage duration of the device information in the database.
Step 104, acquiring weighted packet information corresponding to a storage period;
after the storage period is obtained, the API server can also request to inquire whether the configuration information carries the weighted packet information correspondingly in the configuration center; the weighted packet information is used to define a storage extension time of the device information.
Step 105, calculating the survival validity period of the equipment information according to the weighted packet information and the storage period;
in the embodiment of the present invention, the validity period of the device information can be calculated after the storage period of the device information and the weighted packet information are acquired.
Step 106, storing the equipment information into a database according to the survival validity period; and the database is used for carrying out expiration marking and data cleaning on the equipment information according to the survival validity period.
After determining the validity period for survival, the device information may be stored to a database based on the validity period for survival, and the database may manage the device information according to the validity period for survival, including expiration marking the device information to clean the device information when the device information is expired.
According to the invention, the expiration marking and data cleaning are carried out on the equipment information stored in the database by calculating the survival validity period of the equipment information so as to realize the timely cleaning of the equipment information, the timeliness is strong, and the occurrence of the data redundancy phenomenon in the database can be reduced.
Referring to fig. 2, fig. 2 is a flowchart illustrating a method for managing device information according to another embodiment of the present invention. The method specifically comprises the following steps:
step 201, receiving a report request of a preset device sent by a client; the reporting request carries equipment information;
in the embodiment of the invention, an interface Application Program (API) server is connected with a client and can receive an equipment information reporting request sent by a client APP, wherein the equipment information records the label information of equipment and the related information of an uploading user.
The device information may specifically include:
user login information, such as the actual mobile phone number of a login user;
equipment code: if the client side obtains the equipment SN code of the equipment;
operating system information: including operating system types, such as Android, IOS, etc.; but also operating system versions, such as the v6.0.0 version, etc.;
client application version information: such as V2.1.0;
the network mode is as follows: such as 4G, 5G, Wi-Fi and the like;
access application ID: an 8-bit length ID, etc.;
and (3) checking the token: such as a 32-bit length check field, etc.
Step 202, carrying out validity check on the equipment information;
in the embodiment of the invention, after the device information is acquired, the validity of the device information can be checked.
In one example, the validation rules may include one or more of the following rules:
1) whether the mobile phone number of the login user accords with a preset mobile phone number format or not is judged, and if the mobile phone number accords with the preset mobile phone number format, the mobile phone number is 11-bit long;
2) whether the device SN code information is null (");
3) whether the operating system is IOS or Android;
4) whether the version number of the application version conforms to the Vx.y.z rule (x, y, z are numbers);
5) whether the network mode is any one of 4G and 5G, Wi-Fi;
6) whether the access application ID exists and satisfies a length check rule (e.g., 8-bit length);
7) it is checked whether the token is present and the check rule is satisfied (e.g. 32 bit length and the token value taken by the cache from the access application ID matches this value).
In addition, a person skilled in the art may set other rules according to actual needs, and the embodiment of the present invention is not limited in this respect.
Step 203, acquiring the storage period of the equipment after the verification is passed;
in the embodiment of the present invention, after the verification is passed, the API server may obtain the storage period corresponding to the device.
In one example, step 203 may comprise: sending the device code to a database; and receiving the storage period of the equipment returned by the database based on the equipment code.
In practice, the device may subscribe for a storage period of device information, such as VIP-7 indicating a 7 day storage period.
Step 204, acquiring weighted packet information corresponding to a storage period;
in the embodiment of the invention, the API server side can send a query request to the configuration center; receiving the weighted packet information corresponding to the storage period returned by the configuration center based on the query request.
In one example, if the weighted packet information indicates VIP:1, this indicates that the memory cycle is automatically added to a 1 day validity period.
Step 205, calculating the survival validity period of the equipment information according to the weighted packet information and the storage period;
after the storage period and the weighting packet information are acquired, the survival validity period of the device information can be calculated according to the weighting packet information and the storage period.
In one example, the calculation rule of the validity-to-live period may be as follows:
TTL is (number of storage cycle days queried by the database + number of cycle days configured in the weighted packet information queried by the configuration center) × 24 × 3600, unit second.
Step 206, generating a report log of the device information;
step 207, sending the equipment information and the reported log to a database according to the survival validity period; and the database is used for carrying out expiration marking and data cleaning on the equipment information according to the survival validity period.
In the embodiment of the invention, the API server can insert the device information and the report log of the device information into the database respectively, and the inserted data are all provided with the survival validity period so as to facilitate the time limit management. After receiving the information, the database returns a corresponding information submission operation result to the API server, where if a return 1 indicates that the writing is successful, and a return 0 indicates that the writing is failed. The API server side can return an operation result to the client side according to the information submitting operation result so as to inform the user equipment whether the information is written successfully or not.
For ease of understanding, the following is illustrated by specific examples:
referring to fig. 3, fig. 3 is a flowchart of an apparatus information management method according to an embodiment of the present invention. The method specifically comprises the following steps:
1) requesting reporting equipment information to an API server through an APP on a client;
2) the API server side requests validity check;
3) the API server side inquires a storage period from a database;
4) the API server receives a storage period returned by the database;
5) the API server side pulls a data self-defined expiration policy (including weighted package information) to the configuration center;
6) the configuration center returns the custom expiration policy to the API server;
7) the API server calculates the validity period of the data survival;
8) the API server stores the equipment information in the database according to the data survival validity period;
9) the database returns an information submission operation result to the API server;
10) and the API server returns an operation result to the client APP according to the information submission operation result.
Further, the database can perform data marking and cleaning compression work according to the survival validity period of the data.
In an embodiment of the present invention, the selected database may be a Cassandra database, which may store data through a flexible Map data structure storage model.
The data Map type stores equipment information fields and specific Value information in a Key/Value form, does not contain repeated data, and can flexibly and conveniently add data, and quickly retrieve, update and delete data according to a Key.
The characteristics of Map storage are as follows:
1) the field increment operation may be implemented by adding a Key/Value Key Value pair Value, and overriding the update if the Key already exists. See in particular fig. 4;
2) the Key/Value Key-Value pair specifying the Key may be removed, with no operation if the Key does not exist. See in particular fig. 5.
Fig. 6 is a data model of Cassandra, and as shown in fig. 6, a key space (Keyspace) is an outermost container of data in Cassandra, and is a container of a list of one or more Column families (Column family).
The column family is a container for orderly collecting rows, each row is an ordered column set, and each row of data can set the survival period policy of the data. By setting the corresponding survival validity period in each row of data, the expiration marking of the data can be realized so as to clear the expired data in real time. Where the column is the basic data structure of Cassandra, containing three values: column Name (Name), value (value), and Timestamp (Timestamp).
As shown in fig. 7, the data expiration marking process specifically includes:
requesting to read database data;
inquiring whether the requested data has data with an expired Time To Live (TTL) or not;
if yes, marking the expired data as tombstone data and returning non-tombstone data;
if not, triggering the operation of inquiring whether the data with the expired validity period exists in the requested data again.
Further, as shown in fig. 8, after the marking of the expired data is completed, the data may be compressed and cleaned, and the specific process includes:
merging records with the same partition key;
keep Timestamp up-to-date record;
deleting the data marked with tombstone;
and (5) sorting and retaining the latest data.
According to the invention, the expiration marking and data cleaning are carried out on the equipment information stored in the database by calculating the survival validity period of the equipment information so as to realize the timely cleaning of the equipment information, the timeliness is strong, and the occurrence of the data redundancy phenomenon in the database can be reduced.
Referring to fig. 9, fig. 9 is a block diagram of an apparatus information management device according to an embodiment of the present invention.
The embodiment of the invention provides an equipment information management device, which is applied to an interface server, wherein the interface server is connected with a client and a database; the device comprises:
a report request receiving module 901, configured to receive a report request of a preset device sent by a client; the reporting request carries equipment information;
the validity checking module 902 is configured to perform validity checking on the device information;
a storage period obtaining module 903, configured to obtain a storage period of the device after the verification passes;
a weighted packet information obtaining module 904, configured to obtain weighted packet information corresponding to a storage period;
a validity-for-survival obtaining module 905 configured to calculate a validity-for-survival period of the device information according to the weighted packet information and the storage period;
a storage module 906, configured to store the device information into a database according to the validity period of life; and the database is used for carrying out expiration marking and data cleaning on the equipment information according to the survival validity period.
In the embodiment of the invention, the equipment information comprises user login information, equipment codes, operating system information, client application version information, a network mode, an access application ID and a check token.
In this embodiment of the present invention, the storage period obtaining module 903 includes:
the device code sending submodule is used for sending the device code to the database;
and the storage period receiving submodule is used for receiving the storage period of the equipment returned by the database based on the equipment code.
In the embodiment of the invention, the interface server is also connected with a preset configuration center; the weighted packet information obtaining module 904 includes:
sending a query request to a configuration center;
and receiving the weighted packet information corresponding to the storage period returned by the configuration center based on the query request.
In an embodiment of the present invention, the storage module 906 includes:
generating a reporting log of the equipment information;
and sending the equipment information and the reported log to a database according to the survival validity period.
An embodiment of the present invention further provides an electronic device, where the device includes a processor and a memory:
the memory is used for storing the program codes and transmitting the program codes to the processor;
the processor is used for executing the equipment information management method of any embodiment of the invention according to instructions in the program codes.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium is used to store a program code, and the program code is used to execute the device information management method according to any embodiment of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can 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 terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal 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 diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.