Disclosure of Invention
The invention provides a method for storing cache data in a text, which is used for solving the problems that when the background of a mobile website stores the cache data in the text in the prior art, the text needs to be established in real time first, and then the cache data is stored in the text, so that the process of caching the data is slow, and the operating efficiency of the background of the mobile website is reduced.
One aspect of the present invention provides a data caching method based on a mobile website, including:
obtaining cache data generated by a background of a website, wherein the website is developed based on a mobile software package;
carrying out serialization processing on the cache data to generate cache data in a character string format;
and sending the cache data in the character string format to a redis database server so that the redis database server stores the cache data in the character string format.
In the method, before the obtaining cache data generated in the background of the website, the method further includes:
receiving a server address of a redis database server input by a user;
correspondingly, the sending the cache data in the string format to the redis database server includes:
and sending the cache data in the character string format to a redis database server indicated by the server address.
In the method, the obtaining cache data generated by the background of the website includes:
determining a cache data receiving path;
and obtaining cache data generated by the background of the website according to the cache data receiving path.
In the method described above, after the sending the cached data in the character string format to the redis database server so that the redis database server stores the cached data in the character string format, the method further includes:
receiving a data processing request sent by a background of the website, and determining first time when the data processing request is received;
sending the data processing request to the redis database server so that the redis database server generates a processing result after processing the cache data requested by the data processing request;
receiving a processing result sent by the redis database server, and determining a second time when the processing result is received;
determining a time difference between the first time and the second time;
and determining whether the time difference is greater than the spent time or not according to preset spent time to generate a cache data processing comparison result, wherein the spent time is the time spent in the background of the website for caching text data.
Another aspect of the present invention provides a data caching apparatus based on a mobile website, including:
the acquisition module is used for acquiring cache data generated by a background of a website, wherein the website is developed based on a mobile software package;
the processing module is used for carrying out serialization processing on the cache data to generate cache data in a character string format;
and the sending module is used for sending the cache data in the character string format to a redis database server so that the redis database server stores the cache data in the character string format.
The apparatus as described above further includes:
the receiving module is used for receiving a server address of a redis database server input by a user before the cache data generated by the background of the website is acquired by the acquiring module;
correspondingly, the sending module is specifically configured to:
and sending the cache data in the character string format to a redis database server indicated by the server address.
In the above apparatus, the obtaining module is specifically configured to:
determining a cache data receiving path;
and obtaining cache data generated by the background of the website according to the cache data receiving path.
In the apparatus as described above, the sending module, after sending the cached data in the character string format to the redis database server so that the redis database server stores the cached data in the character string format, is further configured to:
receiving a data processing request sent by a background of the website, and determining first time when the data processing request is received;
sending the data processing request to the redis database server so that the redis database server generates a processing result after processing the cache data requested by the data processing request;
receiving a processing result sent by the redis database server, and determining a second time when the processing result is received;
determining a time difference between the first time and the second time;
and determining whether the time difference is greater than the spent time or not according to preset spent time to generate a cache data processing comparison result, wherein the spent time is the time spent in the background of the website for caching text data.
According to the method, cache data generated by a background of a website are obtained, wherein the website is developed based on a mobile software package; carrying out serialization processing on the cache data to generate cache data in a character string format; and sending the cache data in the character string format to a redis database server so that the redis database server stores the cache data in the character string format. The cache data generated finally by the website based on the mobile software package development is stored in the redis database server, the data caching efficiency is improved, and the background operation efficiency of the mobile website is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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.
Fig. 1 is a flowchart of a data caching method based on a mobile website according to an embodiment of the present invention, and as shown in fig. 1, the method of the embodiment includes:
step 101, cache data generated by a background of a website is obtained, and the website is developed based on a moodle software package.
In this embodiment, specifically, the moodle is an open source learning management software package, and the development user can develop a website for issuing the network course by using the moodle software package, and the access user can classify and search the network course on the website, and learn the course nature according to the needs of the access user. In the process of using the website, cache data generated by the background of the website can be acquired.
And 102, carrying out serialization processing on the cache data to generate the cache data in a character string format.
In this embodiment, specifically, the buffer data is serialized, so that the buffer data in the character string format can be generated.
And 103, sending the cache data in the character string format to a redis database server so that the redis database server stores the cache data in the character string format.
For example, the redis plug-in can be written first, a redis directory is created under a cache/stop directory of a website developed based on a moodle software package, the redis directory stores redis plug-in programs, wherein the redis plug-in includes language packages such as lang/en/cache _ redis.php, test files/lib _ testability, file addresses for configuring address information of the redis server, core packages such as the disp plug-in, the redis directory, and the core packages such as the disp plug-in, the obtained address information of the redis server, and the version of the reds plug-in can be installed to the website based on the developed version of the remote plug-in.
Therefore, the cache data in the character string format acquired in step 102 can be sent to a redis database server through a redis plug-in, and the redis database server stores the cache data in the character string format. Meanwhile, the updated cache data can be periodically written into a disk of the redis database server through the redis plug-in, or the modified cache data can be written into an additional record file of the redis database server through the redis plug-in.
In the embodiment, cache data generated by a background of a website developed based on a mobile software package are acquired, the cache data are serialized to generate cache data in a character string format, and the cache data in the character string format are sent to a redis database server, so that the redis database server stores the cache data. Therefore, cache data generated finally by the website developed based on the mobile software package are stored in the redis database server, the efficiency of caching the data is improved, and the operation efficiency of the background of the mobile website is improved.
Fig. 2 is a flowchart of a data caching method based on a mobile website according to a second embodiment of the present invention, as shown in fig. 2, on the basis of the first embodiment, before step 101 in the first embodiment, the method further includes:
step 201, receiving a server address of a redis database server input by a user.
In this embodiment, specifically, the user may set a server address of the redis database server in a website developed based on the mobile software package. For example, the server address of the Redis database server may be configured under a "website management- > plug-in- > cache storage- > Redis" directory of a website developed based on the moodle software package.
Correspondingly, step 103 specifically includes:
and sending the cache data in the character string format to a redis database server indicated by the server address.
In this embodiment, specifically, according to the server address of the redis database server determined by the user in step 201, the redis database server indicated by the server address is determined, so that the cache data in the character string format is sent to the redis database server indicated by the server address.
According to the method and the device for caching the cache data of the website developed based on the mobile software package, the server address of the redis database server input by the user is received, so that the cache data in the character string format is sent to the redis database server indicated by the server address, the user can change the server address of the redis database server, and caching of the cache data of the website developed based on the mobile software package is facilitated.
Further, on the basis of the above embodiment, step 101 specifically includes:
determining a cache data receiving path;
and obtaining cache data generated by the background of the website according to the cache data receiving path.
In this embodiment, specifically, a cache data receiving path is generated in the background of the website developed based on the mobile software package, and the cache data generated in the background of the website developed based on the mobile software package is acquired through the cache data receiving path.
Further, on the basis of the foregoing embodiment, after the step 102 sends the cached data in the character string format to the redis database server, so that the redis database server stores the cached data in the character string format, the method further includes:
receiving a data processing request sent by a background of a website, and determining first time when the data processing request is received;
sending the data processing request to a redis database server so that the redis database server processes cache data requested by the data processing request and generates a processing result;
receiving a processing result sent by a redis database server, and determining a second time when the processing result is received;
determining a time difference between the first time and the second time;
and determining whether the time difference is greater than the time spent according to the preset time spent to generate a cache data processing comparison result, wherein the time spent is the time spent in the background of the website for caching the text data.
In this embodiment, specifically, a data processing request sent by a background of a website developed based on a mobile software package may be received, where the data processing request may be a request for obtaining cache data, a request for setting a value of the cache data, or a request for deleting the cache data; at the same time, a first time when the data processing request is received is determined. Sending the data processing request to a redis database server, and generating a processing result after the redis database server processes cache data requested by the data processing request; if the data processing request is a request for obtaining the cache data, a processing result of successfully obtaining the data can be generated; if the data processing request is a request for deleting the cached data, a processing result that the data is successfully deleted may be generated. And then receiving a processing result returned by the redis database server, and determining a second time when the processing result is received. And subtracting the first time from the second time to obtain the time difference between the first time and the second time. Presetting time spent for caching text data based on a background of a website developed by a mobile software package; the text data caching process is that when the background of the mobile website developed based on the mobile software package stores the cached data in the text, the text is firstly established in real time, and then the cached data is stored in the text. Comparing the spent time with the time difference to determine whether the time difference is greater than the spent time, thereby generating a cache data processing comparison result; if the time difference is smaller than the time spent, the generated cache data processing comparison result shows that the mode of caching the cache data of the website developed based on the moodle software package through the redis database is superior to the mode of caching the cache data of the website developed based on the moodle software package through the text data cache; if the time difference is larger than the time spent, the generated cache data processing comparison result shows that the mode of caching the cache data of the website developed based on the moodle software package by the text data cache is superior to the mode of caching the cache data of the website developed based on the moodle software package by a redis database. According to the test, the time difference is smaller than the time spent, so that the mode of caching the cache data of the website developed based on the mobile software package through the redis database is superior to the mode of caching the cache data of the website developed based on the mobile software package through the text data cache. For example, the cache performance test of the cache data can be performed through a directory of 'website management- > plug-in- > cache- > Testperformance' of a website developed based on a moodle software package.
In the embodiment, whether the time difference is greater than the time spent or not is determined according to the preset time spent, and a cache data processing comparison result is generated, wherein the time spent is the time spent when the background of the website caches the text data; therefore, the mode of caching the cache data of the website developed based on the mobile software package through the redis database is better than the mode of caching the cache data of the website developed based on the mobile software package through the text data cache.
Fig. 3 is a schematic structural diagram of a data caching device based on a mobile website according to a third embodiment of the present invention, and as shown in fig. 3, the data caching device based on the mobile website according to the third embodiment of the present invention includes:
the acquisition module 31 is configured to acquire cache data generated by a background of a website, where the website is developed based on a mobile software package;
the processing module 32 is configured to perform serialization processing on the cache data to generate cache data in a string format;
the sending module 33 is configured to send the cache data in the character string format to the redis database server, so that the redis database server stores the cache data in the character string format.
The data caching device based on the mobile website of the present embodiment can execute the data caching method based on the mobile website provided in the present embodiment, which is similar to the implementation principle, and is not described herein again.
In the embodiment, cache data generated by a background of a website developed based on a mobile software package are acquired, the cache data are serialized to generate cache data in a character string format, and the cache data in the character string format are sent to a redis database server, so that the redis database server stores the cache data. Therefore, cache data generated finally by the website developed based on the mobile software package are stored in the redis database server, the efficiency of caching the data is improved, and the operation efficiency of the background of the mobile website is improved.
Fig. 4 is a schematic structural diagram of a data caching device based on a mobile website according to a fourth embodiment of the present invention, and based on the third embodiment, as shown in fig. 4, the data caching device based on a mobile website according to the present embodiment further includes:
a receiving module 41, configured to receive a server address of a redis database server input by a user before the obtaining module 31 obtains the cache data generated by the background of the website;
correspondingly, the sending module 33 is specifically configured to:
and sending the cache data in the character string format to a redis database server indicated by the server address.
The obtaining module 31 is specifically configured to:
determining a cache data receiving path;
and obtaining cache data generated by the background of the website according to the cache data receiving path.
The sending module 33 is further configured to, after sending the cached data in the character string format to the redis database server so that the redis database server stores the cached data in the character string format, further:
receiving a data processing request sent by a background of a website, and determining first time when the data processing request is received;
sending the data processing request to a redis database server so that the redis database server processes cache data requested by the data processing request and generates a processing result;
receiving a processing result sent by a redis database server, and determining a second time when the processing result is received;
determining a time difference between the first time and the second time;
and determining whether the time difference is greater than the time spent according to the preset time spent to generate a cache data processing comparison result, wherein the time spent is the time spent in the background of the website for caching the text data.
The data caching device based on the mobile website of this embodiment can execute the data caching method based on the mobile website provided in the second embodiment of the present invention and the foregoing embodiments, and the implementation principles are similar, and are not described herein again.
In the embodiment, the server address of the redis database server input by the user is received, so that the cache data in the character string format is sent to the redis database server indicated by the server address, and the user can also change the server address of the redis database server, thereby facilitating the cache of the cache data of the website developed based on the moodle software package; and cache data finally generated by the website developed based on the mobile software package are stored in the redis database server, so that the efficiency of caching the data is improved, and the running efficiency of the background of the mobile website is improved. Determining whether the time difference is greater than the time spent according to the preset time spent, and generating a cache data processing comparison result, wherein the time spent is the time spent when a background of the website caches the text data; therefore, the mode of caching the cache data of the website developed based on the mobile software package through the redis database is better than the mode of caching the cache data of the website developed based on the mobile software package through the text data cache.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; 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.