Summary of the invention
The present invention aims to provide a kind of method and apparatus that empties internal storage data, and it can solve in the internal memory can be with the data presentation of this metadata cache class on other irrelevant page, thereby influences client's use problem.
According to an aspect of the present invention, provide a kind of method that empties internal storage data, comprising:
Whether there is assignment function in the function of judgment data cache class;
If exist, then carry out described assignment function and give null value.
Preferably, described deterministic process comprises:
Whether the title of function of judging described metadata cache class is identical with the title of assignment function, if identical, then this function is described assignment function.
Preferably, when the number of the function of described metadata cache class is two when above, after current assignment function is carried out assign operation, also comprise:
Employing order or chain type travel through the function of next described metadata cache class, and carry out described deterministic process.
According to another aspect of the present invention, also provide a kind of device that empties internal storage data, comprising:
Whether recognition unit exists assignment function in the function of judgment data cache class;
The assignment unit is carried out described assignment function and is given null value.
Preferably, also comprise:
The traversal unit, be used for number when the function of described metadata cache class and be two when above, after assign operation was carried out with current assignment function in described assignment unit, employing order or chain type traveled through the function of next described metadata cache class, and triggered described recognition unit and carry out deterministic process.
Method and apparatus of the present invention, owing to search the function that has data in internal memory automatically, therefore, can effectively avoid resident in the internal memory has the function of data when being called once more, can be on other irrelevant page with the data presentation of this function, thus the problem of client's use influenced; Improved user's use experience.
Embodiment
Below with reference to the accompanying drawings and in conjunction with the embodiments, describe the present invention in detail.For ease of understanding method and apparatus of the present invention.
Describe method embodiment one of the present invention in detail below in conjunction with Fig. 1, the embodiment one of the inventive method may further comprise the steps:
S11: whether have assignment function in the function of judgment data cache class;
S12:, then carry out described assignment function and give null value if exist.
Method of the present invention can realize in various Object oriented programming environment, as Java, C++ etc., providing embodiments of the invention two below, is example explanation the present invention with the ActionFORM metadata cache class in the STRUTS framework, simply introduces STRTUS exploitation framework below at first:
Struts is the ingredient of Apache Jakarta project.This project goal is for setting up the framework of increasing income that the Java web application provides.By using the Struts framework can improve and improve Java Server Pages (JSP), Servlet, tag library and the application of Object-oriented Technique in web application.Struts is a kind of realization of MVC, and it combines Jsp well, Java Servlet, JavaBean, technology such as Taglib.Visualization model controller MVC is the abbreviation of Model-View-Controller, and it is a Design Mode commonly used during Web uses.MVC has weakened the coupling between service logic interface and the data-interface, allows the view layer more be full of variety simultaneously.
The effect of controller (Controller) is to accept request from client, and selects to carry out correspondent service logic, then response results is sent back to client.Controller is realized by ActionServlet class and Action class in Struts, and ActionServlet mainly is responsible for accepting the HTTP request, and the Action class is responsible for calling the method for model, the flow process of the more state of new model, and help controlling application program.
The view layer mainly is to realize that by JSP the page shows.It receives the data among JavaBean and the Action Form, utilizes html, taglib, bean, label video datas such as logic.
In Struts, mainly there are three kinds of bean objects, be respectively: Action, ActionForm, EJB or Java Bean object.ActionForm is used for encapsulating client requests information, and Action obtains the data among the ActionForm, is handled by EJB or JavaBean again.
Because the function that data in the ActionFORM object is not emptied among the STRUTS manually empties data in the function if adopt, and can cause efficient low excessively, and can not in time empty.
Therefore, increase new function T ools.resetForm (FormName) among the embodiment two, this function can empty the data of metadata cache class in RAM resident.After this function is called, can continuous ergodic data cache class might be at each function of RAM resident data, and judge one by one that each function is whether resident in internal memory data are arranged, this function is resident in internal memory data if judge, then will call this function, give null value this function resident data value in internal memory.
Referring to Fig. 2, comprising:
S21: obtain all functions in the FORM metadata cache class,
For FORM metadata cache class, may at first obtain these functions to a plurality of functions should be arranged;
S22: each function in the traversal FORM metadata cache class;
In when traversal, the structure of arrays that returns travels through each function, or travels through according to the link structure of function, as order, chain type, tree-like etc., travels through according to the form of former method function preservation;
S23: whether first three character of the function of judgement is set;
For each function, whether there is parameter name in the discriminant function to the internal memory assignment, if exist, then carry out S24, in this embodiment, the metadata cache class is in the RAM resident data, be because it has called assignment function set, therefore, as long as function is when having the set parameter name, think that then RAM resident has data in this function; Otherwise execution in step S22 continues traversal;
S24: by invoke function call SET method, and the biography parameter value is an empty string.
Because the function itself that finds out is exactly an assignment function, therefore, directly calls execution and gets final product, and needn't use other assignment function, call and carry out this function, give null value, the data of function in internal memory are emptied.
Method of the present invention can be carried out after function call, also can carry out before function call.By method of the present invention, the data of metadata cache class in internal memory can be emptied, avoid this metadata cache time-like of other routine call, the data of this metadata cache class in internal memory appear on the page.
The present invention also provides a kind of device that empties internal storage data, referring to Fig. 3, comprising:
Whether recognition unit exists assignment function in the function of judgment data cache class;
The assignment unit is carried out described assignment function and is given null value.
Preferably, also comprise:
The traversal unit, be used for number when the function of described metadata cache class and be two when above, after assign operation was carried out with current assignment function in described assignment unit, employing order or chain type traveled through the function of next metadata cache class, and triggered described recognition unit and carry out deterministic process.
From above description, as can be seen, the present invention travels through each function, and empty the resident data of assignment function in internal memory that traveled through, avoided a plurality of page programs to call same metadata cache time-like, with the data presentation of this metadata cache class in internal memory on other irrelevant page, thereby influence client's use.
Obviously, those skilled in the art should be understood that, above-mentioned each module of the present invention or each step can realize with the general calculation device, they can concentrate on the single calculation element, perhaps be distributed on the network that a plurality of calculation element forms, alternatively, they can be realized with the executable program code of calculation element, carry out by calculation element thereby they can be stored in the memory storage, perhaps they are made into each integrated circuit modules respectively, perhaps a plurality of modules in them or step are made into the single integrated circuit module and realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The above only is the preferred embodiments of the present invention; be not limited to the present invention; for a person skilled in the art, various changes and variation can be arranged, revise, be equal to replacement, improvement etc., all should be included within protection scope of the present invention the present invention.