CN111753228A - Data request method and device, computer readable medium and electronic equipment - Google Patents

Data request method and device, computer readable medium and electronic equipment Download PDF

Info

Publication number
CN111753228A
CN111753228A CN201910907702.0A CN201910907702A CN111753228A CN 111753228 A CN111753228 A CN 111753228A CN 201910907702 A CN201910907702 A CN 201910907702A CN 111753228 A CN111753228 A CN 111753228A
Authority
CN
China
Prior art keywords
data
target
image
request
target image
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
CN201910907702.0A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910907702.0A priority Critical patent/CN111753228A/en
Publication of CN111753228A publication Critical patent/CN111753228A/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/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the disclosure provides a data request method, a data response method, a data request device, a data response device, a computer readable medium and electronic equipment, and relates to the technical field of network communication. The data request method comprises the following steps: detecting whether the cache contains target data, and if the cache does not contain the target data, sending a data acquisition request aiming at the target data to a server; acquiring return data of the server responding to the data acquisition request so as to load a target image corresponding to the return data; and analyzing the image data of the target image to acquire the target data. The data response method comprises the following steps: receiving a data acquisition request of a client, and reading target data corresponding to the data acquisition request; converting the target data into attribute values of pixel points to obtain a target image; and sending the target image to the client. The technical scheme of the embodiment of the disclosure can improve the efficiency of data interaction.

Description

Data request method and device, computer readable medium and electronic equipment
Technical Field
The present disclosure relates to the field of network communication technologies, and in particular, to a data request method, a data response method, a data request apparatus, a data response apparatus, a computer-readable medium, and an electronic device.
Background
With the increasing popularity of networks, the development of information technology is more and more prosperous. Webpage interaction reaches unprecedented breadth and depth, and front-end development technology grows like spring shoots after raining, so that more and more people begin to pay attention to the front-end user experience.
The data on the front-end page needs to be provided in the background, when the front-end needs to render the page, a request needs to be sent to the server to obtain the data, and some obtained data can be cached in the front-end, so that the data can be read from the cache when needed next time. However, most of the data is not cached in the front end, for example, the data exceeds the cookie capacity, and for the data that the front end cannot actively cache, the data needs to be passed back and forth between the client and the server many times, so that the request for the data takes much time, which affects the rendering of the front end page.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The inventor finds that, in the related art, data requested by a front end is not actively cached, and connection between a client and a server is required to be performed to acquire the data from the server every time data rendering is performed, so that the data is transmitted between the client and the server for multiple times, and the data request efficiency is low.
In view of the above, it is an object of the embodiments of the present disclosure to provide a data request method, a data response method, a data request device, a data response device, a computer readable medium and an electronic device, so as to overcome the above problems at least to some extent.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to a first aspect of the embodiments of the present disclosure, there is provided a data request method, including:
detecting whether the cache contains target data, and if the cache does not contain the target data, sending a data acquisition request aiming at the target data to a server;
acquiring return data of the server responding to the data acquisition request so as to load a target image corresponding to the return data;
and analyzing the image data of the target image to acquire the target data.
In an exemplary embodiment of the present disclosure, the detecting whether the cache contains the target data includes:
and if the cache contains the target image, determining that the cache contains the target data.
In an exemplary embodiment of the present disclosure, the parsing the image data of the target image to obtain the target data includes:
and determining characters corresponding to all pixel points in the image data respectively to obtain the target data.
In an exemplary embodiment of the present disclosure, after detecting whether the cache contains the target data, the method further includes:
and if the cache contains the target image, rendering the target data corresponding to the target image to a page so as to display the target data.
According to a second aspect of the embodiments of the present disclosure, there is provided a data response method, including:
receiving a data acquisition request of a client, and reading target data corresponding to the data acquisition request;
converting the target data into attribute values of pixel points to obtain a target image;
and sending the target image to the client.
In an exemplary embodiment of the present disclosure, the converting the target data into attribute values of pixel points to obtain a target image includes:
determining binary codes corresponding to the characters in the target data respectively to obtain a one-dimensional array corresponding to the target data;
dividing the one-dimensional array according to the representation mode of the attribute values to obtain array elements corresponding to all the pixel points respectively;
and generating a target image by using the array elements corresponding to the pixel points respectively.
In an exemplary embodiment of the present disclosure, sending the target image to the client includes:
and generating a link of the target image, and returning the link to the data acquisition request.
According to a third aspect of the embodiments of the present disclosure, there is provided a data request apparatus including:
the request sending module is used for detecting whether the cache contains target data or not, and sending a data acquisition request aiming at the target data to the server side if the cache does not contain the target data;
the data acquisition module is used for acquiring return data of the server responding to the data acquisition request so as to load a target image corresponding to the return data;
and the data analysis module is used for analyzing the image data of the target image to acquire the target data.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a data response apparatus, including:
the request receiving module is used for receiving a data acquisition request of a client and reading target data corresponding to the data acquisition request;
the data determination module is used for converting the target data into attribute values of pixel points so as to obtain a target image;
and the request response module is used for sending the target image to the client.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements the data request method as described in the first aspect of the embodiments above, or the data response method as described in the second aspect of the embodiments above.
According to a sixth aspect of an embodiment of the present disclosure, there is provided an electronic apparatus including: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a data request method as described in the first aspect of the embodiments above or a data response method as described in the second aspect of the embodiments above.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
in the technical solutions provided by some embodiments of the present disclosure, on one hand, the server converts data requested by the client into a target image, and sends the target image to the client, so that the data needing interaction is staticized, and caching is facilitated. On the other hand, the client needs to load the target image after receiving the target image, active cache of the target image can be achieved, subsequent data can be directly obtained from the cache when needed, multiple data requests to the server are avoided, data request efficiency can be improved, and user experience can be improved. On the other hand, the data can be cached without modifying the script by converting the requested data into the image, so that the operation is simple, the labor is saved, and the robustness is good.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty. In the drawings:
FIG. 1 schematically shows a system architecture diagram for implementing a data request method or a data response method in an embodiment in accordance with the present disclosure;
FIG. 2 schematically shows a flow diagram of a data request method according to an embodiment of the disclosure;
FIG. 3 schematically illustrates a flow chart of a data response method according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a flow diagram of a data response method according to another embodiment of the present disclosure;
FIG. 5 schematically illustrates an interaction flow diagram of a data request method or a data response method according to an embodiment of the present disclosure;
FIG. 6 schematically shows a block diagram of a data requesting device according to an embodiment of the present disclosure;
FIG. 7 schematically shows a block diagram of a data response apparatus according to an embodiment of the present disclosure;
FIG. 8 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
First, in an exemplary embodiment of the present disclosure, a system architecture for implementing a data request method or a data response method is provided. Referring to fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send request instructions or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for shopping-like websites browsed by users using the terminal devices 101, 102, 103. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the data request method provided by the embodiment of the present disclosure is generally executed by the terminal device 101, and accordingly, the data request apparatus is generally disposed in the terminal device 101; the data response method provided by the embodiment of the present disclosure is generally executed by the server 105, and accordingly, the data response device may be disposed in the server 105.
Based on the system architecture 100, the present disclosure provides a data request method. As shown in fig. 1, the data request method may include the steps of:
s210, detecting whether the cache contains target data or not, and if the cache does not contain the target data, sending a data acquisition request aiming at the target data to a server;
s220, acquiring return data of the server responding to the data acquisition request to load a target image corresponding to the return data;
and S230, analyzing the image data of the target image to acquire the target data.
According to the data request method provided by the exemplary embodiment, on one hand, when the cache does not contain the target data, the data acquisition request is sent to the server, so that the number of times of interaction with the server can be reduced, and the interaction efficiency is improved. On the other hand, the image is actively loaded through the return data sent by the server, and the requested data is stored in the cache, so that the data can be directly obtained from the cache when the data is required subsequently, the data requesting speed is improved, and the front-end page rendering is facilitated.
A detailed description will be given below of specific embodiments of the respective steps of the data requesting method in the present embodiment.
In step S210, it is detected whether the cache contains the target data, and if the cache does not contain the target data, a data acquisition request for the target data is sent to the server.
The target data may be data required by the front end page for rendering the front end page, such as rendering a table in the page. And rendering the target data on a front-end page so as to be convenient for a user to view and use. Therefore, the target data may include data included in the server, such as user information and user operation records, or may include other data, such as order information, and the like, which is not limited in this embodiment.
If the client needs the target data, the client can firstly inquire the target data from the cache, and if the cache is detected not to contain the target data, the client can send a data acquisition request aiming at the target data to the server. The data obtaining request may include information of an interface for obtaining data, and the client may perform data transmission with the server through the interface, for example, an interface for obtaining user information, an interface for obtaining order information, and the like. In addition, the data obtaining request may further include a plurality of request parameters, and when the server receives the data obtaining request, the server may query the database for the target data by using the request parameters, for example, the request parameters may be id (Identity document, account number), and the like. However, the data obtaining request may further include other information, such as identification information of the client, and this embodiment is not particularly limited to this.
For example, the client may send a data obtaining request to the server through an HTTP protocol, where the HTTP protocol includes multiple request methods, and the data obtaining request may be a get method. The get method is a method for requesting a specified resource, and thus target data required by a client is acquired using the method.
In step S220, the obtaining server responds to the return data of the data obtaining request to load the target image corresponding to the return data.
After receiving the data acquisition request, the server may respond to the request, screen out target data from the database by using request parameters included in the request, and return the target data to the client in the form of an image. The client can set the data type of the acquired data when sending the data acquisition request, and can receive the data returned by the server responding to the request through an object of an image type. In addition, the return data sent by the server can be received through other data types, such as binary data types and the like.
For example, when the client sends the data obtaining request, the client may set the return data as a binary object, for example, a responseType value in the data obtaining request is blob, where the responseType parameter is used in the get method to define a type of the return data, that is, the type of the return data is set as blob, and the blob is a binary file type.
Since the return data sent by the server to the client may be an image, in step S210, the target image in the cache may also be detected, and if the cache contains the target image, it may also be determined that the cache contains the target data. However, if the return data sent by the server to the client is of other data types, such as text, it may also be detected whether the cache contains the target text, and if the cache does not contain any type of target data, it may be determined that the cache does not contain the target data.
Generally, for data which cannot be cached by a client, setting can be performed through an HTML script, so that the data is cached by the client according to the script, but in this way, codes need to be written manually, the data which needs to be cached is defined one by one, and the method is troublesome. In this embodiment, due to the characteristic that the client performs active caching on the image, the client loads the target image after acquiring the target image through the HTTP request, so that the target image is loaded into the cache. In step S210, if the cache includes the target image, the step S230 may be directly performed without sending a data obtaining request to the server, and the target image is used to obtain the required target data, so as to avoid repeated data interaction, improve interaction efficiency, and shorten response time of the front-end page.
In step S230, the image data of the target image is parsed to obtain the target data.
The image data of the target image may include the resolution of the image, or an image color model, such as RGB, LAB, etc., and may also include other data of the image, such as color depth of the image, etc. In this embodiment, each pixel point in the target image may be converted into a corresponding character, so as to obtain target data, and one pixel point may be converted into one character or a character string, so as to obtain all characters corresponding to the target image, that is, the target data. The component value of each pixel point in the image data of the target image can be represented as a number, and the character represented by the number can be determined by using a unicode encoding mechanism. Unicode may include a set of characters in which a unique binary code is defined for each character of each language, enabling cross-language, cross-platform data conversion and processing.
Specifically, the component values of each pixel point in the target image may be obtained first, and each pixel point may include three component values, i.e., a red component, a green component, a blue component, e.g., rgb (204,173,191), etc. The returned data may be converted into binary data by defining the data type of the returned data of the data acquisition request, and thus the component values of the pixel points may also include numbers represented in binary form, for example, rgb (1011101,0111001,0000111), and the like. After the component values of each pixel are determined, each component value can be converted into a character. A binary number is defined for each character in a Unicode coding mechanism, so that the character corresponding to each component value can be determined by utilizing the Unicode coding, and further, a character string corresponding to each pixel point is determined. And arranging the character strings corresponding to the pixel points of the target image in sequence according to the sequence of the pixel points to obtain target data.
In addition, each pixel point in the target image may include four component values, RGBA, i.e., red component, green component, blue component, and transparency, such as RGBA (204,173,191,0.7), and the four components may be respectively converted into corresponding characters, so as to obtain a character string corresponding to each pixel point. In other embodiments, the image data may be converted into characters in other manners to obtain the target data, for example, each pixel point corresponds to one character to obtain a character string corresponding to the target image, and these also belong to the protection scope of the present disclosure.
After the target data is obtained, data processing may be performed on the target data, for example, the target data is sorted according to a preset format, and a special symbol included in the target data is removed. The target data may then be displayed in a front-end page, such as a table or the like, for viewing by the user. When the target data is needed next time, the target image can be directly obtained from the cache without requesting the server, the target data can be analyzed, the one-time request and the multiple use are realized, and the response speed of the page is improved.
Therefore, in this embodiment, if the cache includes the target image, the request does not need to be sent to the server, the target data corresponding to the target image may be directly obtained through step S230, and then the target data may be rendered to the page to show the target data to the user.
Based on the system architecture 100 shown in fig. 1, exemplary embodiments of the present disclosure also provide a data response method. As shown in fig. 3, the data response method may include the steps of:
s310, receiving a data acquisition request of a client, and reading target data corresponding to the data acquisition request;
s320, converting the target data into attribute values of pixel points to obtain a target image;
s330, sending the target image to the client.
In the data response method provided by the exemplary embodiment, target data required by the client is converted into an image and sent to the client, so that the loading speed of the client can be increased. And the image can be used for multiple times, so that the request times of a client are reduced, and the pressure of a server is reduced.
Next, each step of the data response method in the present embodiment will be described in detail.
In step S310, a data obtaining request of a client is received, and target data corresponding to the data obtaining request is read.
And when a data acquisition request of the client is received, calling a corresponding data interface according to the data acquisition request so as to inquire target data required by the client. Data required by the client can be stored in a database of the server, and a database query statement can be determined through the data acquisition request, so that target data can be screened out. Moreover, the target data required by the client can be processed according to the agreed format, the data can be appointed to start and end with a special symbol, and the meaning indicated by the symbol can also be agreed, for example, the data format is { code:0, data: { name: 'zhangsan' }.
In step S320, the target data is converted into attribute values of pixel points to obtain a target image.
The target data can be converted into attribute values of the pixel points. The attribute value may include a value of a pixel point, such as (0,0, 0). The number corresponding to each character in the target data can be determined by utilizing Unicode uniform coding, and the number is used as a brightness value of a pixel point, so that a target image is synthesized. A pixel point of an image may include multiple components, such as three color components of RGB, four components of RGBA, and so on. Therefore, the number corresponding to each character in the target data can be used as the value of one component, so that the values of a plurality of components are determined, a pixel point is represented by the components, and the target data is converted into a plurality of pixel points. And filling the determined values of the pixel points into the image by using an image drawing tool, for example, generating an image instance through a Canvas element in a webpage, and assigning values to each pixel point in the image instance to generate a target image.
As shown in fig. 4, acquiring a target image from target data may be performed by:
s410, determining binary codes corresponding to all characters in the target data respectively to obtain a one-dimensional array corresponding to the target data;
s420, dividing the one-dimensional array according to the representation mode of the attribute values to obtain array elements corresponding to all pixel points respectively;
and S430, generating a target image by using the array elements corresponding to the pixel points respectively.
In step S410, a plurality of characters may be included in the target data, and a binary code corresponding to each character may be determined through Unicode encoding, for example, NULL may be represented as 00000000, etc. The binary codes corresponding to each character in the target data are sequentially stored through the one-dimensional array, the binary code corresponding to the first character can be used as the first element of the array, and the like, and the coded data corresponding to the target data are sequentially stored into the one-dimensional array.
In step S420, the pixel points of the image may be represented by a plurality of color models, such as an RGB mode, an RGBA mode, and the like, where different color models represent different numbers of luminance components used for one pixel, for example, RGB includes three color components, RGBA includes three color components and one transparency component, and the grayscale image may represent one pixel point by one luminance component. And dividing the one-dimensional array corresponding to the target data according to the brightness component contained in each pixel point. If a pixel is represented by three color components, every three in the one-dimensional array can be divided into one group, so that the attribute value of each pixel point is obtained. Or, a pixel point may be represented by four components, and then every four elements in the one-dimensional array may be divided into one group, so as to obtain an attribute value of each pixel point.
In step S430, a target image can be generated using the array elements corresponding to each pixel point. For example, element A in one-dimensional array A0、A1、A2、A3Represents a pixel point, A4、A5、A6、A7Indicating a second pixel, and so on. And assigning values to the pixel points by using each element in the one-dimensional array through a drawing tool so as to generate a target image.
It is understood that in other embodiments of the present disclosure, the conversion of the target data into the attribute value of the pixel point may also be implemented in other manners, for example, the codes corresponding to the characters in the target data are expressed in formats of decimal, hexadecimal, and the like, and then the decimal and hexadecimal codes are assigned to the pixel point to generate the target image, or each character in the target data represents a pixel point, and the like, which also belong to the protection scope of the present disclosure.
Illustratively, the server may create a Canvas C through a Canvas, first obtain data ImgData of all pixel points on the Canvas C, and may obtain data of each pixel point on the Canvas by using a getImageData method. And then replacing the data in the ImgData by the elements in the one-dimensional array, namely, assigning the value of the element corresponding to the first pixel point in the one-dimensional array to the value of the first pixel point in the ImgData, and assigning each pixel point in the ImgData, thereby completing conversion and obtaining new image data ImgData 2. Finally, the obtained ImgData2 is output to the canvas C, and the PutImageData method can be used for outputting the ImgData2 to the canvas C, so that the target image is obtained. Also, the canvas C may be converted to a Data URL formatted image using the TODataURL method, which may return a Data URL formatted image, i.e., the target image. Data URL is a method provided by HTML (Hyper Text Markup Language) that enables direct embedding of an image in a web page.
In step S330, the target image is sent to the client.
And after the target image is generated, transmitting the target image to the client as the return data of the data acquisition request. Illustratively, by generating a link to the target image, the link may be sent to the client, thereby accessing the target image via the link. And when the target image is returned to the client, the caching time of the target image can be set according to the type of the target data, and if the target data is updated at regular intervals, the time interval is set as the caching time of the target image. After the cache time of the target image is set, the target image can be hit in the time, and the target image is invalid after the cache time is exceeded, and the server can be requested to acquire data again. The target image may be cached in other caching methods, for example, a negotiation cache, and the like, but the present embodiment is not limited thereto.
Fig. 5 shows an interaction flow in this embodiment, and as shown in fig. 5, this embodiment may include steps S501 to S514. Wherein:
a page may refer to a front-end page of a client application, where the page performs data interaction via http protocol with a server. In step S501, if the front-end page requests to obtain data, it needs to determine whether the request is a first request, and if the request is the first request, the request is sent to the server to obtain data corresponding to the request stored on the server. Then, in step S502, the server responds to the request. In step S503, the server, in response to the request, may read information corresponding to the request from the database. In step S504, the read information is uniformly encoded, all Unicode codes corresponding to the information are determined, and all the codes are stored in an array. In step S505, every four elements in the array are divided into one group, resulting in a plurality of groups. In step S506, the four elements in each group are respectively assigned to the rgba four components, and one pixel point is represented by the four components, thereby determining a plurality of pixel points. In step S507, a canvas is generated by the rgba value of the pixel point, that is, the obtained plurality of pixel points are filled into the canvas. In step S508, the canvas object is converted into an image format. In step S509, the image is stored in the server. In step S510, the server may return the image to the page in the form of a link.
At the server, the data requested by the client page is acquired by executing the above steps S502 to S509, and the data is converted into an image. The server may then return the data requested by the client page to the page in the form of a link to the image in step S510.
For the client, in step S511, after the client page requests the image link, the image corresponding to the image link may be directly loaded, so as to load the image into the cache. In step S512, the cached image is put into the canvas, so as to obtain the component value of each pixel point of the image, i.e., the rgba value. In step S513, the rgba value of the image is parsed to obtain the requested information; by converting the rgba value into characters, the content of the requested information is determined. In step S514, the information requested by the page is rendered to the page, thereby completing the rendering of the current information. When the information is requested next time, the client has cached the image, and the cached image can be directly obtained through step S511, and then the requested data is analyzed out and rendered into the page.
Further, an exemplary embodiment of the present disclosure also provides a data requesting apparatus, which may be used to implement the data requesting method of the present disclosure.
As shown in fig. 6, the data request apparatus 600 may include a request sending module 610, a data obtaining module 620, and a data parsing module 630. Wherein:
a request sending module 610, configured to detect whether the cache includes target data, and send a data obtaining request for the target data to the server if the cache does not include the target data;
a data obtaining module 620, configured to obtain return data of the server responding to the data obtaining request, so as to load a target image corresponding to the return data;
a data analysis module 630, configured to analyze the image data of the target image to obtain the target data.
In an exemplary embodiment of the disclosure, the request sending module 610 may be configured to determine that the cache contains the target data if the cache contains the target image.
In an exemplary embodiment of the disclosure, the data analysis module 630 may be configured to determine characters corresponding to each pixel point in the image data, so as to obtain the target data.
In an exemplary embodiment of the present disclosure, the data requesting apparatus 600 further includes a data rendering module. The data rendering module may be configured to render target data corresponding to the target image to a page if the cache includes the target image, so as to display the target data.
Further, an exemplary embodiment of the present disclosure also provides a data response device, which may be used to implement the data response method of the present disclosure.
As shown in fig. 7, the data response apparatus 700 may include a request receiving module 710, a data determining module 720, and a request response module 730. Wherein:
a request receiving module 710, configured to receive a data obtaining request of a client, and read target data corresponding to the data obtaining request;
a data determining module 720, configured to convert the target data into attribute values of pixel points to obtain a target image;
a request response module 730, configured to send the target image to the client.
In an exemplary embodiment of the disclosure, the data determining module 720 may include a code determining unit, configured to determine binary codes corresponding to characters in the target data, respectively, so as to obtain a one-dimensional array corresponding to the target data; the coding dividing unit is used for dividing the one-dimensional array according to the representation mode of the attribute value to obtain array elements corresponding to all the pixel points respectively; and the image generation unit is used for generating the target image by utilizing the array elements corresponding to the pixel points respectively.
In an exemplary embodiment of the disclosure, the request response module 730 may be configured to generate a link to the target image, and return the link to the data acquisition request.
For details that are not disclosed in the embodiments of the apparatus of the present disclosure, reference is made to the embodiments of the method described above in the present disclosure for details that are not disclosed in the embodiments of the apparatus of the present disclosure, since each functional module of the data request apparatus and the data response apparatus of the present disclosure corresponds to a step of the above-described example embodiments of the data request method and the data response method.
Referring now to FIG. 8, shown is a block diagram of a computer system 800 suitable for use in implementing the electronic devices of embodiments of the present disclosure. The computer system 800 of the electronic device shown in fig. 8 is only an example, and should not bring any limitations to the function and scope of use of the embodiments of the present disclosure.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for system operation are also stored. The CPU801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program executes the above-described functions defined in the system of the present application when executed by the Central Processing Unit (CPU) 801.
It should be noted that the computer readable media shown in the present disclosure may be computer readable signal media or computer readable storage media or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer-readable signal medium may include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software, or may be implemented by hardware, and the described units may also be disposed in a processor. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to implement the data request method or the data response method as described in the above embodiments.
For example, the electronic device may implement the following as shown in fig. 2: step S210, detecting whether the cache contains target data, if the cache does not contain the target data, sending a data acquisition request aiming at the target data to a server; step S220, return data of the server responding to the data acquisition request is acquired so as to load a target image corresponding to the return data; step S230, analyzing the image data of the target image to obtain the target data.
As another example, the electronic device may implement the following as shown in fig. 3: step S310, receiving a data acquisition request of a client, and reading target data corresponding to the data acquisition request; step S320, converting the target data into attribute values of pixel points to obtain a target image; and step S330, sending the target image to the client.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (11)

1. A method of requesting data, comprising:
detecting whether the cache contains target data, and if the cache does not contain the target data, sending a data acquisition request aiming at the target data to a server;
acquiring return data of the server responding to the data acquisition request so as to load a target image corresponding to the return data;
and analyzing the image data of the target image to acquire the target data.
2. The method of claim 1, wherein detecting whether the cache contains the target data comprises:
and if the cache contains the target image, determining that the cache contains the target data.
3. The method of claim 1, wherein the parsing the image data of the target image to obtain the target data comprises:
and determining characters corresponding to all pixel points in the image data respectively to obtain the target data.
4. The method of claim 2, wherein after detecting whether the cache contains the target data, further comprising:
and if the cache contains the target image, rendering the target data corresponding to the target image to a page so as to display the target data.
5. A data response method, comprising:
receiving a data acquisition request of a client, and reading target data corresponding to the data acquisition request;
converting the target data into attribute values of pixel points to obtain a target image;
and sending the target image to the client.
6. The method of claim 5, wherein converting the target data into attribute values of pixel points to obtain a target image comprises:
determining binary codes corresponding to the characters in the target data respectively to obtain a one-dimensional array corresponding to the target data;
dividing the one-dimensional array according to the representation mode of the attribute values to obtain array elements corresponding to all the pixel points respectively;
and generating a target image by using the array elements corresponding to the pixel points respectively.
7. The method of claim 5, wherein sending the target image to the client comprises:
and generating a link of the target image, and returning the link to the data acquisition request.
8. A data request apparatus, comprising:
the request sending module is used for detecting whether the cache contains target data or not, and sending a data acquisition request aiming at the target data to the server side if the cache does not contain the target data;
the data acquisition module is used for acquiring return data of the server responding to the data acquisition request so as to load a target image corresponding to the return data;
and the data analysis module is used for analyzing the image data of the target image to acquire the target data.
9. A data response apparatus, comprising:
the request receiving module is used for receiving a data acquisition request of a client and reading target data corresponding to the data acquisition request;
the data determination module is used for converting the target data into attribute values of pixel points so as to obtain a target image;
and the request response module is used for sending the target image to the client.
10. A computer-readable medium, on which a computer program is stored, which program, when being executed by a processor, carries out a data request method according to any one of claims 1 to 4, or a data response method according to any one of claims 5 to 7.
11. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out a data request method as claimed in any one of claims 1 to 4 or a data response method as claimed in any one of claims 5 to 7.
CN201910907702.0A 2019-09-24 2019-09-24 Data request method and device, computer readable medium and electronic equipment Pending CN111753228A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910907702.0A CN111753228A (en) 2019-09-24 2019-09-24 Data request method and device, computer readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910907702.0A CN111753228A (en) 2019-09-24 2019-09-24 Data request method and device, computer readable medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN111753228A true CN111753228A (en) 2020-10-09

Family

ID=72672879

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910907702.0A Pending CN111753228A (en) 2019-09-24 2019-09-24 Data request method and device, computer readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111753228A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112163176A (en) * 2020-11-02 2021-01-01 北京城市网邻信息技术有限公司 Data storage method and device, electronic equipment and computer readable medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102438045A (en) * 2011-12-07 2012-05-02 深圳市深信服电子科技有限公司 Method and system for pre-fetching web page, and method for accessing web page
CN104484142A (en) * 2014-12-01 2015-04-01 广东威创视讯科技股份有限公司 Jointing wall web page display method and system
CN106341453A (en) * 2016-08-23 2017-01-18 北京永信至诚科技股份有限公司 High-speed virtual desktop agent building method and high-speed virtual desktop agent building system based on HTML5
US20170359434A1 (en) * 2016-06-14 2017-12-14 Microsoft Technology Licensing, Llc Web caching with image and local storage
CN107729516A (en) * 2017-10-26 2018-02-23 北京百度网讯科技有限公司 Single page application methods of exhibiting and device, server, equipment and computer-readable recording medium
CN108259563A (en) * 2017-12-12 2018-07-06 平安普惠企业管理有限公司 Data cache method, device, server and storage medium
CN108494742A (en) * 2018-03-05 2018-09-04 杭州泰酷科技有限公司 A kind of web data encrypted transmission mode applied to browser

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102438045A (en) * 2011-12-07 2012-05-02 深圳市深信服电子科技有限公司 Method and system for pre-fetching web page, and method for accessing web page
CN104484142A (en) * 2014-12-01 2015-04-01 广东威创视讯科技股份有限公司 Jointing wall web page display method and system
US20170359434A1 (en) * 2016-06-14 2017-12-14 Microsoft Technology Licensing, Llc Web caching with image and local storage
CN106341453A (en) * 2016-08-23 2017-01-18 北京永信至诚科技股份有限公司 High-speed virtual desktop agent building method and high-speed virtual desktop agent building system based on HTML5
CN107729516A (en) * 2017-10-26 2018-02-23 北京百度网讯科技有限公司 Single page application methods of exhibiting and device, server, equipment and computer-readable recording medium
CN108259563A (en) * 2017-12-12 2018-07-06 平安普惠企业管理有限公司 Data cache method, device, server and storage medium
CN108494742A (en) * 2018-03-05 2018-09-04 杭州泰酷科技有限公司 A kind of web data encrypted transmission mode applied to browser

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112163176A (en) * 2020-11-02 2021-01-01 北京城市网邻信息技术有限公司 Data storage method and device, electronic equipment and computer readable medium

Similar Documents

Publication Publication Date Title
CN107622135B (en) Method and apparatus for displaying information
CN109522483B (en) Method and device for pushing information
CN104333531A (en) Network resource sharing and obtaining method, device, terminal
CN113382083B (en) Webpage screenshot method and device
CN113808231B (en) Information processing method and device, image rendering method and device, and electronic device
CN110866040A (en) User portrait generation method, device and system
CN113467775A (en) Method and device for generating page
CN109062560B (en) Method and apparatus for generating information
CN109101309B (en) Method and apparatus for updating user interface
CN112307369A (en) Short link processing method, device, terminal and storage medium
CN113076294A (en) Information sharing method and device
CN108694120B (en) Method and device for testing service component
CN112581568B (en) Dynamic poster generation method, device, server and storage medium
CN113760438A (en) Page display method and device for webpage application
CN111753228A (en) Data request method and device, computer readable medium and electronic equipment
CN112558933A (en) Component rendering method and device, readable medium and electronic equipment
CN114039801B (en) Short link generation method, short link analysis system, short link analysis equipment and storage medium
CN112947900A (en) Web application development method and device, server and development terminal
CN112486482A (en) Page display method and device
CN113779018A (en) Data processing method and device
CN112749353A (en) Processing method and device of webpage icon
CN111131354B (en) Method and apparatus for generating information
CN111723106A (en) Prediction method and device for spark QL query statement
CN113542335A (en) Information sharing method and device, electronic equipment and storage medium
CN111125501A (en) Method and apparatus for processing information

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