CN111381917A - Data reading and writing method and device - Google Patents
Data reading and writing method and device Download PDFInfo
- Publication number
- CN111381917A CN111381917A CN201811646402.3A CN201811646402A CN111381917A CN 111381917 A CN111381917 A CN 111381917A CN 201811646402 A CN201811646402 A CN 201811646402A CN 111381917 A CN111381917 A CN 111381917A
- Authority
- CN
- China
- Prior art keywords
- data
- shared
- storage
- reading
- name
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 67
- 230000032683 aging Effects 0.000 claims abstract description 68
- 230000004044 response Effects 0.000 claims description 14
- 238000007405 data analysis Methods 0.000 claims description 5
- 230000004927 fusion Effects 0.000 claims description 3
- 230000008569 process Effects 0.000 description 27
- 238000010586 diagram Methods 0.000 description 10
- 238000004590 computer program Methods 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a data reading and writing method and a data reading and writing device, and mainly aims to enable local storage to correctly read and write shared data with timeliness and improve the application range of the shared data in the local. The main technical scheme of the invention is as follows: generating data to be stored according to the shared data and the aging parameters thereof in the write request; writing the data to be stored into a local storage by using a local storage interface to obtain shared storage data, wherein the name of the shared storage data is configured as the name of the shared data; when a reading request of the shared data is received, extracting shared storage data with corresponding names by using a local reading interface according to the shared data names in the reading request; analyzing the aging parameters in the shared storage data; and determining the data content responding to the reading request by using the aging parameter. The invention is used for reading and writing data in the local storage.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a data reading and writing method and device.
Background
At present, most of third-party Application programs (APPs) in the intelligent terminal adopt a development mode of HTML5+ webview, and when a user performs page switching, the APP displays a newly-built webview and loads a well-developed HTML5 page to the user. When data needs to be shared among a plurality of HTML5 pages in the APP, the data can be shared in a localstorage mode, namely, the data to be shared is stored in the localstorage through javascript, and the data to be shared is taken out of the localstorage through javascript when the pages are switched. However, the localstorage storage technology in the current HTML5 has no time limit, so that the validity of the shared data cannot be determined during page switching of the shared data with time limit, and the loaded shared data has inaccurate information due to overdue.
In this regard, the current solution is to identify shared data, and not use localstorage storage for shared data with time limits, i.e., not share these data between pages. But rather requires the switched page to make a separate request for such data. For the APP, when multiple pages need to load the shared data with time limit, the data content requested by the pages is increased, and the data traffic used by the user is increased.
Disclosure of Invention
In view of the above problems, the present invention provides a data reading and writing method and device, and mainly aims to enable local storage to correctly read and write shared data with timeliness, and improve the local application range of the shared data.
In order to achieve the purpose, the invention mainly provides the following technical scheme:
in one aspect, the present invention provides a data reading and writing method, which specifically includes:
generating data to be stored according to the shared data and the aging parameters thereof in the write request;
writing the data to be stored into a local storage by using a local storage interface to obtain shared storage data, wherein the name of the shared storage data is configured as the name of the shared data;
when a reading request of the shared data is received, extracting shared storage data with corresponding names by using a local reading interface according to the shared data names in the reading request;
analyzing the aging parameters in the shared storage data;
and determining the data content responding to the reading request by using the aging parameter.
In another aspect, the present invention provides a data reading/writing apparatus, which specifically includes:
the data processing unit is used for generating data to be stored according to the shared data in the write request and the aging parameters thereof;
the data writing unit is used for writing the data to be stored obtained by the data processing unit into a local storage by using a local storage interface to obtain shared storage data, wherein the name of the shared storage data is configured to be the name of the shared data;
the data reading unit is used for extracting shared storage data with corresponding names by using a local reading interface according to the names of the shared data in the reading request when the reading request of the shared data is received;
the data analysis unit is used for analyzing the aging parameters in the shared storage data extracted by the data reading unit;
and the data response unit is used for determining the data content responding to the reading request by utilizing the time efficiency parameter analyzed by the data analysis unit.
In another aspect, the present invention provides a storage medium, where the storage medium includes a stored program, where the program controls, when running, a device on which the storage medium is located to execute the above-mentioned data reading and writing method.
In another aspect, the present invention provides a processor, where the processor is configured to execute a program, where the program executes the above-mentioned data reading and writing method.
By means of the technical scheme, the data reading and writing method and device provided by the invention are optimized and improved on the basis of the localstorage storage technology in the existing HTML5, when time-efficient shared data need to be written into a local storage, the shared data and time-efficient parameters corresponding to the shared data are integrated and processed into data to be stored, and the data to be stored is stored into the shared storage data by utilizing a native localstorage storage technology interface. When the shared storage data needs to be read from the local storage, the corresponding shared storage data can be acquired by using the native local storage interface, then the aging parameter of the shared data in the shared storage data is analyzed, whether the shared storage data is expired is judged by using the aging parameter, and whether the shared data in the shared storage data is fed back is determined according to the judgment result. Therefore, the time-sensitive data needing to be shared are processed and then written into the local storage through the native interface, and the read data are judged to be time-sensitive and then whether to feed back is determined during reading, so that the problem that the time-sensitive data which is limited in time cannot be stored in the existing HTML5 is solved, the applicable types of the locally stored shared data are more diversified, the flow of repeatedly requesting to obtain the same data is saved for a user, the response efficiency of page display is improved, and the use experience of the user is improved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 shows a flowchart of a data read/write method according to an embodiment of the present invention;
fig. 2 is a flow chart of a data writing method according to an embodiment of the present invention;
fig. 3 is a flow chart of a data reading method according to an embodiment of the present invention;
fig. 4 is a block diagram illustrating a data reading/writing apparatus according to an embodiment of the present invention;
fig. 5 is a block diagram showing another data reading/writing apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
The embodiment of the invention provides a data reading and writing method, which has no limitation on locally stored shared data with timeliness, can feed back effective shared data when the shared data in local storage is used, and avoids the problem of page data loading error caused by shared data failure. The specific steps are shown in fig. 1, and the method comprises the following steps:
and step 101, generating data to be stored according to the shared data and the aging parameters thereof in the write request.
When storing data locally, the conventional HTML5 only stores the shared data itself, and in this step, when there is shared data to be stored locally, it needs to first determine whether the shared data has an aging parameter, where the aging parameter is used to describe an effective time period of the shared data, for example, the effective time of data a is 10 seconds, then the aging parameter of data a is 10 seconds, of course, a specific expression is not limited, for example, the unit may be other time units such as milliseconds, and the value of the corresponding aging parameter also needs to be further converted. For the case that the shared data has no aging parameter, this step will configure an aging parameter for the data, and the value of the aging parameter is infinite.
In this step, the data to be stored is composed of shared data and corresponding aging parameters, where the aging parameters are used to determine whether the shared data is valid when the shared data is read. In order to accurately judge, the time for writing the shared data into the local storage is also saved in the data to be stored.
In addition, a write request is generally a write request that a system initiates to store shared data in a local storage when the data read by a page is determined to be the shared data.
And 102, writing the data to be stored into a local storage by using a local storage interface to obtain shared storage data, wherein the name of the shared storage data is configured as the name of the shared data.
The step is a process of writing the shared storage data, which is the same as the process of writing the shared data into the local storage by the existing HTML5, that is, the shared data name corresponding to the data to be stored is also written while the data to be stored is written, so that when the content of the data to be stored is more, the data to be stored can be retrieved quickly during reading. Since the process of writing to the local storage is the same, the detailed implementation of the writing step will not be described in detail.
The two steps are implementation steps for writing the shared data into the local storage in the implementation, that is, after the shared data to be written and the corresponding aging parameters are processed, new data to be stored are generated, and then the data to be stored is written by the existing writing technology of the local storage, so as to obtain the shared storage data stored in the local storage.
And 103, when a reading request of the shared data is received, extracting the shared storage data with the corresponding name by using the local reading interface according to the shared data name in the reading request.
The reading request is a data reading request initiated when the data content is judged to be the data stored in the local storage according to the data content loaded by the page. The read request generally carries the name of the shared data of the read data, i.e. the name corresponding to the shared data is stored together when the shared data is written. And inquiring the shared data name to acquire corresponding shared storage data.
In this step, the local read interface used in step 102 and the local storage interface used in step 102 are corresponding data interfaces, that is, a set of dedicated interfaces for reading and writing the shared data to the local storage by the existing HTML 5. Thus, the reading process is the same as the existing process of HTML5 finding and reading shared data from local storage. The difference is that instead of the shared data itself, the shared storage data read in this step is data that is composed of the shared data itself and the corresponding aging parameters.
And 104, analyzing the aging parameters in the shared storage data.
Specifically, according to the data structure in the shared storage data, the position or field in the shared storage data where the aging parameter is stored is determined, and then the value stored in the position or field, i.e., the value of the aging parameter, is extracted.
Specifically, the step determines whether the shared data in the shared storage data is invalid according to the aging parameter, and when determining that the shared data is in an valid state, the shared data in the shared storage data is used as the data content of the response read request, and when determining that the shared data is in an invalid state, the shared data invalid information is fed back to the requester, so that the requester can obtain the shared data again through the server.
The above steps 103 to 105 are data reading processes corresponding to the previous two steps, the reading process is the reverse process of the data writing operation, after the shared storage data is read, the read shared storage data is analyzed, whether the shared data in the read shared storage data is invalid is judged by using the analyzed aging parameter, and then the data content responding to the reading request is determined according to the judgment result. Thus, the existing HTML5 technology can be used for reading and writing shared data with timeliness in the local storage.
As can be seen from the specific implementation manner in the foregoing embodiment, in the data reading and writing process, two independent processes may be performed, that is, a process of writing shared data, that is, steps 101 and 102, and a process of reading shared data, that is, steps 103 to 105. The two processes can be independently executed, and through the writing process, the shared data is processed, so that the local storage does not need to distinguish the written data in a time-sensitive manner, and the processed shared data can be written into the local storage for reading when other pages are loaded as long as the shared data is processed; through the reading process, the read shared storage data can be analyzed, whether the aging of the shared data in the read shared storage data is expired or not is judged, direct feedback can be performed on the shared data which is not expired, and reloading is needed on the shared data which is expired. Therefore, the method and the device can realize that the time-efficient shared data is stored in the local storage, so that the time-efficient shared data can be directly called from the local storage when the page is loaded, the data loading speed is increased, and the flow for reloading the data is saved for a user.
In order to further clarify the above-mentioned data read/write method in detail, the following will describe the processes of writing shared data and reading shared data by way of example in practical application, respectively.
First, a process of writing shared data is described with reference to fig. 2, which mainly includes:
And 202, fusing the shared data, the aging parameters and the shared data name into data to be stored by using a preset storage interface.
And 203, writing the data to be stored into a local storage by using the local storage interface to obtain shared storage data.
In practical application, it is assumed that page a in APP on the terminal obtains data "this isdata from server" through service query, and the data is also used in page B, and the validity period of the data is 1 minute. Then the data is saved to local storage:
firstly, the content of the data (this is data from server), the aging parameter (1 minute), and the shared data name (assumed as "testData") are required to be obtained, wherein the shared data name may be an attribute description carried by the data itself or may be set by a user in a self-defined manner.
Secondly, fusing the acquired data content by using a preset storage interface, specifically, the storage interface needs to be preset, and in this embodiment, the storage interface is defined as: secItem (key, value, time); in this embodiment, the fusion data may further obtain data to be stored by constructing object data, specifically, create object data param, param { data: 'this data from server', Date: new Date (), and outward data: 6000}, where param represents the data content of the shared data, and param represents the time point at which the data is stored, i.e., the write time of the shared data, and param represents the aging parameter. To create the object data, a data structure of the shared storage data, that is, a data structure of the object data, needs to be preset, where parameters to be determined in the data structure at least include: shared data, age parameters, and data write time. Therefore, when the object data is created, the corresponding parameter data is acquired according to the data structure and fused to obtain the shared storage data.
Thirdly, the HTML5 is used to provide the data to be stored obtained by storing the native localStorage, the interface is localstorage.setitem (key, value), wherein key represents the name of the shared data, value represents the content of the data to be stored, and corresponding to the execution result, the data to be stored and the corresponding shared data name testData are written into the local storage by calling the interface localstorage.setitem ('testData', param), so as to obtain the shared storage data.
Next, a specific process of reading the written shared memory data according to the present invention is described by the embodiment shown in fig. 3 corresponding to the process of writing in fig. 2, and in fig. 3, the written shared data "this is data fromserver" shown in fig. 2 is taken as an example of read contents, which includes:
and 301, extracting the shared storage data with the corresponding name by using the local reading interface according to the shared data name in the reading request.
The local reading interface is a native localStorage reading interface provided by the HTML5, that is, localStorage getitem (key) corresponding to localStorage setitem (key, value). And matching the shared data name in the local storage through the reading interface, namely judging whether the same key exists in the locally stored data, if so, extracting the corresponding shared storage data according to the shared data name, namely acquiring the corresponding value according to the key. At this time, the value is object data, i.e., param in the previous embodiment.
And step 302, analyzing the aging parameters in the shared storage data.
This step is to obtain param. amplified from param.
The content of this step is the same as that of step 105, and the following description of fig. 3 in practical application can be referred to for specific implementation:
first, a call interface needs to be preset, and a shared data name in the read request is determined through the call interface, in this embodiment, the interface is defined as localstoragemanager. Then, by calling the interface, it can be determined that the name of the shared data to be acquired is testData, i.e., localstoragemanager
Second, according to the testData, shared storage data corresponding to the testData, i.e., object data param, is acquired from the local storage using a native data read interface localstorage.
Thirdly, as can be seen from the contents in fig. 2, param records the contents of shared data, write time (time written into local storage), aging parameter, etc., so that the aging parameter 6000 ms and write time, which is assumed to be time1, can be analyzed from param, and at the same time, the read time of the read request (i.e., the request sending time of the read request) is obtained, which is assumed to be time2, the difference between time2 and time1 is calculated, the difference is compared with the aging parameter 6000 ms, when the difference is not greater than the aging parameter, the shared data is proved to be valid, the shared data 'this is data from' in param is fed back, and when the difference is greater than the aging parameter, the shared data is proved to be invalid, and when the null value is fed back, the null value can be represented by null, and when the user obtains the feedback of the null value, the data obtaining request needs to be sent to the server again. And then, storing the acquired effective data into a local storage.
Through the steps shown in fig. 2 and fig. 3, the process steps of writing data into the local storage and then reading out the data are described in detail, compared with the process of locally storing data implemented by the existing HTML5, the present invention implements writing of shared data with timeliness on the basis of the above steps, and ensures that the output shared data is valid when reading according to the time-efficiency parameters, and feeds back null values for invalid shared data. Therefore, the application range of the local storage in the shared data storage process is widened, the flow waste caused by the fact that the user obtains the data again is reduced, and meanwhile, the efficiency of page data loading is improved.
Further, as an implementation of the method shown in fig. 1 to fig. 3, an embodiment of the present invention provides a data reading and writing apparatus, which is capable of storing shared data with timeliness, and determining data content responded when reading the shared data according to a timeliness parameter of the data. For convenience of reading, details in the foregoing method embodiments are not described in detail again in this apparatus embodiment, but it should be clear that the apparatus in this embodiment can correspondingly implement all the contents in the foregoing method embodiments. As shown in fig. 4, the apparatus specifically includes:
the data processing unit 41 is configured to generate data to be stored according to the shared data in the write request and the aging parameter thereof;
a data writing unit 42, configured to write the data to be stored obtained by the data processing unit 41 into a local storage by using a local storage interface, so as to obtain shared storage data, where a name of the shared storage data is configured as a name of the shared data;
a data reading unit 43, configured to, when a read request for the shared data is received, extract, according to a shared data name in the read request, shared storage data with a corresponding name by using a local reading interface;
a data analysis unit 44, configured to analyze the aging parameter in the shared storage data extracted by the data reading unit 43;
a data response unit 45, configured to determine the data content responding to the read request by using the aging parameter parsed by the data parsing unit 44.
Further, as shown in fig. 5, the data response unit 45 includes:
a first obtaining module 451, configured to obtain, from the shared storage data, a time when the data to be stored is written into a local storage;
a second obtaining module 452, configured to obtain a request sending time of the read request;
a determining module 453, configured to determine whether a difference between the request issuing time obtained by the second obtaining module 452 and the time written into the local storage obtained by the first obtaining module 451 is greater than the aging parameter;
a data response module 454, configured to, when the determining module 453 determines that the difference is not greater than the aging parameter, extract corresponding shared data from the shared storage data as the data content in response to the read request, and when it determines that the difference is greater than the aging parameter, take a null value as the data content in response to the read request.
Further, as shown in fig. 5, the data processing unit 41 includes:
an obtaining module 411, configured to obtain shared data, and an aging parameter and a name of the shared data according to a write request;
a data fusion module 412, configured to fuse, by using a preset storage interface, the shared data acquired by the acquisition module 411, the aging parameter, and the shared data name into data to be stored.
Further, the data writing unit 42 further includes:
a setting module 421, configured to preset a data structure of the shared storage data, where the data structure at least includes: sharing data, aging parameters, and data write-in time;
the writing module 422 is configured to generate the shared storage data according to the shared data and the aging parameter included in the data to be stored and the time for writing the data to be stored in the local storage, and set the shared storage data name as the name of the shared data.
Further, as shown in fig. 5, the data reading unit 43 includes:
a matching module 431, configured to match the shared data name in a local storage by using a local reading interface;
an extracting module 432, configured to, when the matching module 431 matches the shared data name, extract shared storage data corresponding to the shared data name.
In summary, the data reading and writing method and apparatus adopted in the embodiments of the present invention are optimized and improved based on the localstorage storage technology in the existing HTML5, and when it is necessary to write time-efficient shared data into the local storage, the shared data and the corresponding time-efficient parameters are integrated into one to-be-stored data, and the to-be-stored data is stored as the shared storage data by using the native localstorage storage technology interface. Therefore, the time-sensitive data needing to be shared are processed and then written into the local storage through the native interface, and the read data are judged to be time-sensitive and then whether to feed back is determined during reading, so that the problem that the time-sensitive data which is limited in time cannot be stored in the existing HTML5 is solved, the applicable types of the locally stored shared data are more diversified, the flow of repeatedly requesting to obtain the same data is saved for a user, the response efficiency of page display is improved, and the use experience of the user is improved.
Further, an embodiment of the present invention further provides a storage medium, where the storage medium includes a stored program, where the program, when running, controls a device in which the storage medium is located to execute the above-mentioned data reading and writing method.
In addition, the embodiment of the invention also provides a processor, wherein the processor is used for running the program, and the data reading and writing method is executed when the program runs.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
It will be appreciated that the relevant features of the method and apparatus described above are referred to one another. In addition, "first", "second", and the like in the above embodiments are for distinguishing the embodiments, and do not represent merits of the embodiments.
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 algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In addition, the memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application 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.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. 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 apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block 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 apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application 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.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims (12)
1. A method for reading and writing data, the method comprising:
generating data to be stored according to the shared data and the aging parameters thereof in the write request;
writing the data to be stored into a local storage by using a local storage interface to obtain shared storage data, wherein the name of the shared storage data is configured as the name of the shared data;
when a reading request of the shared data is received, extracting shared storage data with corresponding names by using a local reading interface according to the shared data names in the reading request;
analyzing the aging parameters in the shared storage data;
and determining the data content responding to the reading request by using the aging parameter.
2. The method of claim 1, wherein the determining data content responsive to the read request using the age parameter comprises:
acquiring the time for writing the data to be stored into a local storage from the shared storage data;
acquiring request sending time of the reading request;
judging whether the difference value between the request sending time and the time written into the local storage is larger than the aging parameter or not;
and if the data content is not larger than the preset value, extracting corresponding shared data from the shared storage data to serve as the data content responding to the reading request, and if the data content is larger than the preset value, taking a null value as the data content responding to the reading request.
3. The method according to claim 1, wherein the generating the data to be stored according to the shared data in the write request and the aging parameter thereof comprises:
acquiring shared data, and an aging parameter and a shared data name of the shared data according to a write-in request;
and fusing the shared data, the aging parameters and the shared data name into data to be stored by using a preset storage interface.
4. The method of claim 3, wherein writing the data to be stored into a local storage by using a local storage interface to obtain shared storage data comprises:
presetting a data structure of the shared storage data, wherein the data structure at least comprises: sharing data, aging parameters, and data write-in time;
and generating the shared storage data according to the shared data and the aging parameters included in the data to be stored and the time for writing the data to be stored into a local storage, and setting the name of the shared storage data as the name of the shared data.
5. The method of claim 4, wherein extracting, by using a local read interface, the shared storage data of the corresponding name according to the shared data name in the read request comprises:
matching the shared data name in a local storage by using a local reading interface;
and if the shared data name exists, extracting the shared storage data corresponding to the shared data name.
6. A data reading/writing apparatus, comprising:
the data processing unit is used for generating data to be stored according to the shared data in the write request and the aging parameters thereof;
the data writing unit is used for writing the data to be stored obtained by the data processing unit into a local storage by using a local storage interface to obtain shared storage data, wherein the name of the shared storage data is configured to be the name of the shared data;
the data reading unit is used for extracting shared storage data with corresponding names by using a local reading interface according to the names of the shared data in the reading request when the reading request of the shared data is received;
the data analysis unit is used for analyzing the aging parameters in the shared storage data extracted by the data reading unit;
and the data response unit is used for determining the data content responding to the reading request by utilizing the time efficiency parameter analyzed by the data analysis unit.
7. The apparatus of claim 6, wherein the data response unit comprises:
the first acquisition module is used for acquiring the time for writing the data to be stored into the local storage from the shared storage data;
a second obtaining module, configured to obtain a request sending time of the read request;
the judging module is used for judging whether the difference value between the request sending time acquired by the second acquiring module and the time written into the local storage acquired by the first acquiring module is greater than the aging parameter or not;
and the data response module is used for extracting corresponding shared data from the shared storage data to serve as the data content responding to the reading request when the judging module determines that the difference is not larger than the aging parameter, and taking a null value as the data content responding to the reading request when the judging module determines that the difference is larger than the aging parameter.
8. The apparatus of claim 6, wherein the data processing unit comprises:
the acquisition module is used for acquiring shared data, and the aging parameters and the names of the shared data according to a write-in request;
and the data fusion module is used for fusing the shared data acquired by the acquisition module, the aging parameters and the shared data name into data to be stored by using a preset storage interface.
9. The apparatus of claim 8, wherein the data writing unit further comprises:
a setting module, configured to preset a data structure of the shared storage data, where the data structure at least includes: sharing data, aging parameters, and data write-in time;
and the writing module is used for generating the shared storage data according to the shared data and the aging parameters included in the data to be stored and the time for writing the data to be stored into a local storage, and setting the name of the shared storage data as the name of the shared data.
10. The apparatus of claim 9, wherein the data reading unit comprises:
the matching module is used for matching the shared data name in a local storage by using a local reading interface;
and the extracting module is used for extracting the shared storage data corresponding to the shared data name when the matching module is matched with the shared data name.
11. A storage medium, comprising a stored program, wherein the program controls a device in which the storage medium is located to execute the data reading and writing method according to any one of claims 1 to 5 when the program runs.
12. A processor, configured to execute a program, wherein the program executes to perform the data reading and writing method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811646402.3A CN111381917A (en) | 2018-12-29 | 2018-12-29 | Data reading and writing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811646402.3A CN111381917A (en) | 2018-12-29 | 2018-12-29 | Data reading and writing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111381917A true CN111381917A (en) | 2020-07-07 |
Family
ID=71216627
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811646402.3A Pending CN111381917A (en) | 2018-12-29 | 2018-12-29 | Data reading and writing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111381917A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114374557A (en) * | 2022-01-07 | 2022-04-19 | 挂号网(杭州)科技有限公司 | Webpage data requesting method and device, electronic equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102902730A (en) * | 2012-09-10 | 2013-01-30 | 新浪网技术(中国)有限公司 | Method and device for reading data based on data cache |
CN103634391A (en) * | 2013-11-26 | 2014-03-12 | 上海合鸿信息技术有限公司 | Method and system for realizing conversation sharing |
CN104461380A (en) * | 2014-11-17 | 2015-03-25 | 华为技术有限公司 | Data storage method and device |
CN107329910A (en) * | 2017-06-27 | 2017-11-07 | 中南大学 | A kind of web front end data based on localStorage are locally stored and access method |
CN107395711A (en) * | 2017-07-17 | 2017-11-24 | 中国农业银行股份有限公司 | Heterogeneous system session access method and relevant apparatus |
CN109032505A (en) * | 2018-06-26 | 2018-12-18 | 深圳忆联信息系统有限公司 | Data read-write method, device, computer equipment and storage medium with timeliness |
-
2018
- 2018-12-29 CN CN201811646402.3A patent/CN111381917A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102902730A (en) * | 2012-09-10 | 2013-01-30 | 新浪网技术(中国)有限公司 | Method and device for reading data based on data cache |
CN103634391A (en) * | 2013-11-26 | 2014-03-12 | 上海合鸿信息技术有限公司 | Method and system for realizing conversation sharing |
CN104461380A (en) * | 2014-11-17 | 2015-03-25 | 华为技术有限公司 | Data storage method and device |
CN107329910A (en) * | 2017-06-27 | 2017-11-07 | 中南大学 | A kind of web front end data based on localStorage are locally stored and access method |
CN107395711A (en) * | 2017-07-17 | 2017-11-24 | 中国农业银行股份有限公司 | Heterogeneous system session access method and relevant apparatus |
CN109032505A (en) * | 2018-06-26 | 2018-12-18 | 深圳忆联信息系统有限公司 | Data read-write method, device, computer equipment and storage medium with timeliness |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114374557A (en) * | 2022-01-07 | 2022-04-19 | 挂号网(杭州)科技有限公司 | Webpage data requesting method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109582303B (en) | General component calling method, device, computer equipment and storage medium | |
CN111241073B (en) | Data quality inspection method and device | |
CN109308254B (en) | Test method, test device and test equipment | |
CN111414377B (en) | Method, device and storage medium for processing structured query statement | |
CN111198772A (en) | Method and system for generating application program interface API | |
CN109977317B (en) | Data query method and device | |
CN114329281A (en) | Rendering server, webpage rendering method and webpage rendering device | |
CN111382183B (en) | Data query method and device | |
CN111126058A (en) | Text information automatic extraction method and device, readable storage medium and electronic equipment | |
CN114297204A (en) | Data storage and retrieval method and device for heterogeneous data source | |
CN111381917A (en) | Data reading and writing method and device | |
CN111459474B (en) | Templated data processing method and device | |
CN112597105A (en) | Processing method of file associated object, server side equipment and storage medium | |
CN112036974A (en) | Service commodity online method, device, equipment and storage medium | |
CN110232155B (en) | Information recommendation method for browser interface and electronic equipment | |
CN112149038A (en) | Browser development method and device, computer equipment and readable storage medium | |
CN112100126B (en) | Excel file-based picture storage and content display method and device | |
CN113268507B (en) | Database data reading system, method and device and electronic equipment | |
CN110908876B (en) | Method and device for acquiring hardware performance data | |
CN107885839B (en) | Method and device for reading information in Word file | |
CN112307305A (en) | Service component preprocessing method, device and equipment | |
CN112541327A (en) | Data reading method and device, electronic equipment and storage medium | |
CN111158873A (en) | System state machine implementation method and device, storage medium and processor | |
CN110968821A (en) | Website processing method and device | |
CN113792137B (en) | Method, system, intelligent terminal and storage medium for searching middle-stage research and development materials |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200707 |