OO caching write, read method and device
Technical field
The present invention relates to caching technology field, particularly relate to a kind of OO caching write, read method and device.
Background technology
For extensive Web (webpage) system, number of users is very big, and the load causing server is the highest, therefore magnetic
Dish readwrite performance is low, needs to use internal memory to improve the performance of whole system as caching.Caching can be directly to great majority
User provides service, it is to avoid the External memory equipment that each request access performance of user is low, thus improves whole system
The efficiency of system.Therefore, caching is particularly important for improving the performance of whole system.
Existing extensive Web system generally uses object oriented language to develop.Object-oriented is that a kind of software is opened
Forwarding method, refers to use encapsulation in programming, inherit and the method for designing such as polymorphic.Encapsulation refers to deposit in real world
The attribute of certain object bind together with behavior, and be placed in a logical block.This logical block is responsible for institute
The attribute described stashes, and all access of outer bound pair object built-in attribute can only be realized by the user interface provided.This
Sample does and both can play the protective effect to object attribute, can improve again the maintainability of software system.Want liking people
Carrying out anything studied, all can regard object from simple integer as to complicated aircraft etc., it can not only represent concrete
Things, moreover it is possible to represent abstract rule, plan or event.Object has state, and an object data value describes its shape
State.Object also has operation, and for changing the state of object, object and operation thereof are exactly the behavior of object.Object implementatio8 data
With the combination of operation, data and operation is made to be packaged in the entity of object.Class is to have the object of identical characteristics and behavior
Abstract.Therefore, class is the abstract of object, to the materialization liking class, it may also be said to, to the example liking class.Class is actually
A kind of data type.Such as, Psittacula alexandri fasciata can be considered as a kind, and concrete Psittacula alexandri fasciata can be considered as an object.Class has
Attribute, it is the abstract of the state of object, and the attribute data structure of class describes.Class has operation, and it is the behavior of object
Abstract, by operation name with realize the method for this operation and describe.
Caching refers to the relief area of data exchange, when a certain hardware data to be read, can first search from caching
The data needed, if having found, directly perform, and then search from next stage storage device if can not find.Due to caching
Read or write speed is more faster than next stage storage device, and therefore caching can help whole system to run quickly.Caching work
Principle is " locality quoted ", including temporal locality and spatial locality.Temporal locality refers to when certain data is interviewed
After asking once, do not cross and how long will be accessed again;Spatial locality refers to CPU (Central
Processing Unit, central processing unit) at a time need certain data, then and being likely to next step, to be accomplished by it attached
Near data.For application program, it is no matter instruction stream or the localized phenomena quoted all can occur in data stream.Due to
The read or write speed of the internal memory of computer is significantly faster than the read or write speed of hard disk, therefore can be temporary transient by the data read from hard disk
Leave in internal memory, just again need not have read from hard disk when of using these data afterwards, thus substantially increase whole
The read or write speed of body, this process is namely based on the aforesaid principle of locality quoted and internal memory is used as the caching of hard disk.
Existing extensive Web system generally uses object oriented language to develop, but current caching technology cannot
It is well adapted for the exploitation demand of Object-Oriented Systems.Specifically, when using caching technology in Object-Oriented Systems at present,
Agreement cannot be general between each class, and research staff needs to separately design serializing and unserializing agreement for each class, with
And develop respectively for each class and debug, causing taking considerable time, and easily make mistakes, whole process efficiency is low.
Summary of the invention
Technical problem
In view of this, the technical problem to be solved in the present invention is, existing caching technology fitting in Object-Oriented Systems
Answering property is poor, causes development efficiency relatively low.
Solution
In order to solve above-mentioned technical problem, according to one embodiment of the invention, it is provided that a kind of OO caching is write
Enter method, including:
In the case of receiving write request, call general object memory interface;
The unique identifier of the object to be written of said write request correspondence is determined by described general object memory interface,
And the key of described object to be written is generated according to described unique identifier;
The parameter type and the parameter format that are specified according to preset protocol by described general object memory interface are treated described
Write object sequence turns to stream, and described preset protocol can be used in the serializing of any class;
By described general object memory interface according to described key by described stream write caching.
For said method, in a kind of possible implementation, by described general object memory interface according to institute
State key by described stream write caching after, described method also includes:
According to described key by described stream write External memory equipment.
For said method, in a kind of possible implementation, by described general object memory interface according to presetting
Described object sequence to be written is turned to stream by parameter type and parameter format that agreement specifies, including:
Determine, by described general object memory interface, all described parameter type that described preset protocol specifies, and determine
The parameter value of all described parameter type that described object to be written is corresponding;
The described parameter format specified according to described preset protocol by described general object memory interface, is preset described
The parameter value of the information of agreement and all described parameter type corresponding to described object to be written is converted to stream.
For said method, in a kind of possible implementation, described parameter type includes: the name of the class belonging to object
Claim parameter, whole Property Name parameters of described object, whole property value parameters of described object, all method of described object
Name parameter, class belonging to described object create the complete of class belonging to the name parameter of method of described object, described object
Whole property value parameters of the class belonging to subordinate's property name parameter and described object.
In order to solve above-mentioned technical problem, according to another embodiment of the present invention, it is provided that a kind of OO caching
Read method, including:
In the case of receiving inquiry request, determine that described inquiry request is corresponding by general object query interface
Key;
If finding, by described general object query interface, the stream that described key is corresponding from described caching, then according to presetting
Described stream is deserialized as object by parameter type and parameter format that agreement specifies, and described preset protocol can be used in any class
Unserializing;
Described object is returned, to respond described inquiry request by described general object query interface.
For said method, in a kind of possible implementation, look into described in being determined by general object query interface
After asking the key that request is corresponding, described method also includes:
If searching the stream corresponding less than described key from described caching, then from outside by described general object query interface
Storage device is searched the stream that described key is corresponding;
If finding the stream that described key is corresponding from described External memory equipment, then the institute specified according to described preset protocol
State parameter type and described parameter format and described stream is deserialized as described object, and return described object, described with response
Inquiry request.
For said method, in a kind of possible implementation, the parameter type specified according to preset protocol and parameter
Described stream is deserialized as object by form, including:
From described stream, obtain the information of described preset protocol, and determine described presetting according to the information of described preset protocol
The described parameter type of agreement regulation and described parameter format;
In the described parameter type specified according to described preset protocol and described parameter format, and described stream all described
The parameter value of parameter type, is deserialized as described object by described stream.
For said method, in a kind of possible implementation, described parameter type includes: the name of the class belonging to object
Claim parameter, whole Property Name parameters of described object, whole property value parameters of described object, all method of described object
Name parameter, class belonging to described object create the complete of class belonging to the name parameter of method of described object, described object
Whole property value parameters of the class belonging to subordinate's property name parameter and described object.
In order to solve above-mentioned technical problem, according to another embodiment of the present invention, it is provided that a kind of OO caching
Writing station, including:
General object memory interface calling module, in the case of receiving write request, calls general object and deposits
Storage interface;
Key generation module, for determining the to be written right of said write request correspondence by described general object memory interface
The unique identifier of elephant, and the key of described object to be written is generated according to described unique identifier;
Serialization module, for the parameter type specified according to preset protocol by described general object memory interface and ginseng
Described object sequence to be written is turned to stream by number format, and described preset protocol can be used in the serializing of any class;
Caching writing module, for caching described stream write according to described key by described general object memory interface.
For said apparatus, in a kind of possible implementation, described device also includes:
External memory equipment writing module, for writing External memory equipment according to described key by described stream.
For said apparatus, in a kind of possible implementation, described serialization module includes:
Parameter value determines submodule, for determining, by described general object memory interface, the institute that described preset protocol specifies
There is a described parameter type, and determine the parameter value of all described parameter type that described object to be written is corresponding;
Serializing submodule, for the described ginseng specified according to described preset protocol by described general object memory interface
Number format, turns the parameter value of all described parameter type corresponding to the information of described preset protocol and described object to be written
It is changed to stream.
For said apparatus, in a kind of possible implementation, described parameter type includes: the name of the class belonging to object
Claim parameter, whole Property Name parameters of described object, whole property value parameters of described object, all method of described object
Name parameter, class belonging to described object create the complete of class belonging to the name parameter of method of described object, described object
Whole property value parameters of the class belonging to subordinate's property name parameter and described object.
In order to solve above-mentioned technical problem, according to another embodiment of the present invention, it is provided that a kind of OO caching
Reading device, including:
Key determines module, in the case of receiving inquiry request, is determined described by general object query interface
The key that inquiry request is corresponding;
Unserializing module, if for finding described key pair by described general object query interface from described caching
Described stream is deserialized as object by the stream answered, the then parameter type specified according to preset protocol and parameter format, described default
Agreement can be used in the unserializing of any class;
First inquiry response module, for returning described object by described general object query interface, described with response
Inquiry request.
For said apparatus, in a kind of possible implementation, described device also includes:
First searches module, if for being searched less than described key from described caching by described general object query interface
Corresponding stream, then search the stream that described key is corresponding from External memory equipment;
Second inquiry response module, if for finding the stream that described key is corresponding from described External memory equipment, then pressing
Described stream is deserialized as described object by the described parameter type and the described parameter format that specify according to described preset protocol, and returns
Return described object, to respond described inquiry request.
For said apparatus, in a kind of possible implementation, described unserializing module includes:
Parameter type and form determine submodule, for obtaining the information of described preset protocol from described stream, and according to
The information of described preset protocol determines the described parameter type and described parameter format that described preset protocol specifies;
Unserializing submodule, for the described parameter type specified according to described preset protocol and described parameter format,
And the parameter value of all described parameter types in described stream, described stream is deserialized as described object.
For said apparatus, in a kind of possible implementation, described parameter type includes: the name of the class belonging to object
Claim parameter, whole Property Name parameters of described object, whole property value parameters of described object, all method of described object
Name parameter, class belonging to described object create the complete of class belonging to the name parameter of method of described object, described object
Whole property value parameters of the class belonging to subordinate's property name parameter and described object.
Beneficial effect
By encapsulation general object memory interface and general object query interface, the serializing that can be used in any class is set
With the preset protocol of unserializing, OO caching wiring method, read method and device according to embodiments of the present invention
Object oriented language can be combined with caching, it is possible to general object memory interface and general object inquiry by encapsulation connect
Cause for gossip is now directly accessed the object in object oriented language, thus greatly reduces development amount, improve exploitation portability and
Efficiency, and the read-write load of External memory equipment can be reduced, the readwrite performance bottleneck problem of solution External memory equipment, thus greatly
Improve greatly systematic function;OO caching wiring method, read method and the device of the embodiment of the present invention are being applied to
In the case of server end, the access speed of server can be greatly improved, support higher concurrently, thus same subscriber amount institute
The number of servers needed is greatly reduced.
According to below with reference to the accompanying drawings detailed description of illustrative embodiments, the further feature of the present invention and aspect being become
Clear.
Accompanying drawing explanation
The accompanying drawing of the part comprising in the description and constituting description together illustrates the present invention's with description
Exemplary embodiment, feature and aspect, and for explaining the principle of the present invention.
Fig. 1 illustrates the flowchart of the most OO caching wiring method;
Fig. 2 illustrates showing of another flowchart of the most OO caching wiring method
It is intended to;
What Fig. 3 illustrated the most OO caching wiring method step S103 implements stream
The schematic diagram of journey figure;
Fig. 4 illustrates the flowchart of the most OO caching read method;
Fig. 5 illustrates showing of another flowchart of the most OO caching read method
It is intended to;
Fig. 6 illustrates in the most OO caching read method step S402 according to default association
Stream is deserialized as the schematic diagram implementing flow chart of object by the parameter type of view regulation and parameter format;
Fig. 7 illustrates the structured flowchart of the most OO caching writing station;
Fig. 8 illustrates the structured flowchart of the most OO caching reading device;
Fig. 9 illustrates an exemplary structural frames of the most OO caching writing station
Figure;
Figure 10 illustrates an exemplary structural frames of the most OO caching reading device
Figure.
Detailed description of the invention
Various exemplary embodiments, feature and the aspect of the present invention is described in detail below with reference to accompanying drawing.In accompanying drawing identical
Reference represent the same or analogous element of function.Although the various aspects of embodiment shown in the drawings, but remove
Non-specifically is pointed out, it is not necessary to accompanying drawing drawn to scale.
The most special word " exemplary " means " as example, embodiment or illustrative ".Here as " exemplary "
Illustrated any embodiment should not necessarily be construed as preferred or advantageous over other embodiments.
It addition, in order to better illustrate the present invention, detailed description of the invention below gives numerous details.
It will be appreciated by those skilled in the art that do not have some detail, the present invention equally implements.In some instances, for
Method well known to those skilled in the art, means, element and circuit are not described in detail, in order to highlight the purport of the present invention.
Embodiment 1
Fig. 1 illustrates the flowchart of the most OO caching wiring method.Such as Fig. 1 institute
Showing, the method specifically includes that
In step S101, in the case of receiving write request, call general object memory interface.
It should be noted that the embodiment of the present invention goes in any system based on object oriented language exploitation,
Such as can apply in the background server of website.
Wherein, general object memory interface can be the general-purpose interface of the object for storing class, for external call.Call
This general object memory interface directly can write the object of any class in the caching of Object-Oriented Systems.
In embodiments of the present invention, in the case of outside interface to write request, external interface calls general right
As memory interface, so that general object memory interface writes, in caching, the object to be written that this write request is corresponding.
In step s 102, determine that the unique of object to be written that write request is corresponding marks by general object memory interface
Know symbol, and generate the key of object to be written according to unique identifier.
Wherein, the unique identifier of object to be written can include a kind of Property Name and this attribute-name of object to be written
Claiming corresponding property value, can uniquely determine this object to be written according to this property value, thus this unique identifier can conduct
Access mark.The key generating object to be written according to unique identifier can be: the character string being converted to by unique identifier
Key as object to be written.
In step s 103, the parameter type specified according to preset protocol by general object memory interface and parameter format
Being written into object sequence and turn to stream, preset protocol can be used in the serializing of any class.
Wherein, stream can be byte stream or character stream, in this no limit.Byte stream is made up of byte, character
Stream is made up of character.In embodiments of the present invention, byte stream can refer to that being written into object is packaged into according to preset protocol
A series of successive bytes;Character stream can refer to that being written into object is packaged into a series of continuation character according to preset protocol.Class can
Think the class that any one object oriented language defines, to the example liking class.
In embodiments of the present invention, the general preset protocol of the serializing that can be used in any class can be pre-designed,
This preset protocol can be called, to realize writing object in the buffer by general object memory interface.Due to without for each
Class separately designs agreement, thus greatly reduces development amount, improves exploitation convenience and development efficiency.
In step S104, by general object memory interface according to key by stream write caching.
In embodiments of the present invention, caching can use internal memory as storage device.Caching can use depositing of key-value pair
Storage mode, it is possible to use hash table is as data structure, and key can be an arbitrary character string, value can also be one arbitrarily
Character string, the corresponding value of key.Hash table can determine the storage position of value according to key, it is achieved thereby that Constant Grade
Search, update and delete.In embodiments of the present invention, the value in key-value pair can refer to stream.
Wherein, step S104 is specifically as follows: write by stream based on hash algorithm according to key by general object memory interface
Enter caching.
The embodiment of the present invention, by being encapsulated as general object memory interface to the process of caching write object, calls this general right
As memory interface, can directly the object of the class in object oriented language be write in caching.
Existing in a kind of possible implementation, before step S101, the method also includes: by class instantiation, generation is treated
Write object, and according to such each attribute defined, this object to be written is carried out assignment.
Fig. 2 illustrates showing of another flowchart of the most OO caching wiring method
It is intended to.As in figure 2 it is shown, the method specifically includes that
In step s 201, in the case of receiving write request, call general object memory interface;
In step S202, determine that the unique of object to be written that write request is corresponding marks by general object memory interface
Know symbol, and generate the key of object to be written according to unique identifier;
In step S203, the parameter type specified according to preset protocol by general object memory interface and parameter format
Being written into object sequence and turn to stream, preset protocol can be used in the serializing of any class;
In step S204, by general object memory interface according to key by stream write caching;
In step S205, according to key, stream is write External memory equipment.
In a kind of possible implementation, after stream write being cached according to key by general object memory interface, root
According to key, stream is write External memory equipment.Here, External memory equipment can be hard disk, in this no limit.Outside storage
Equipment is used for permanent memory.
What Fig. 3 illustrated the most OO caching wiring method step S103 implements stream
The schematic diagram of journey figure.As it is shown on figure 3, the parameter type specified according to preset protocol by general object memory interface and parameter lattice
Formula is written into object sequence and turns to stream, including:
In step S301, determine, by general object memory interface, all parameter types that preset protocol specifies, and really
The parameter value of all parameter types that fixed object to be written is corresponding;
In step s 302, the parameter format specified according to preset protocol by general object memory interface, by default association
The information of view and the parameter value of all parameter types corresponding to object to be written are converted to stream.
Wherein, the information of preset protocol can include the mark of preset protocol and the version number of preset protocol.Parameter format
The order of parameters in stream can be included.Parameter format can also include the coding standard of parameter, such as, the coding mark of parameter
Standard is that (American Standard Code for Information Interchange, Unite States Standard information exchanges ASCII
Code).
In a kind of possible implementation, parameter type includes: the name parameter of the class belonging to object, object whole
It is right that class belonging to Property Name parameter, whole property value parameters of object, the name parameter of all method of object, object creates
Whole property values ginseng of the class belonging to whole Property Name parameters of the class belonging to the name parameter of the method for elephant, object and object
Number etc..
Such as, the parameter of object to be written includes: the title of the class belonging to object to be written, whole genus of object to be written
Property described in title, whole property values of object to be written, the title of all method of object to be written, object to be written class wound
Build belonging to whole Property Names and the object to be written of class belonging to the title of the method for this object to be written, object to be written
Whole property values of class.
So, by encapsulation general object memory interface, the preset protocol of the serializing that can be used in any class, root are set
Object oriented language can be combined with caching according to the OO caching wiring method of the embodiment of the present invention, it is possible to pass through
The general object memory interface of encapsulation realizes writing direct the object in object oriented language, thus greatly reduces development
Amount, improves portability and the efficiency of exploitation, and the read-write that can reduce External memory equipment loads, and solves the reading of External memory equipment
Write performance bottleneck problem, thus it is greatly improved systematic function;By the OO caching wiring method of the embodiment of the present invention
In the case of being applied to server end, the access speed of server can be greatly improved, support higher concurrently, thus identical use
Number of servers required for the amount of family is greatly reduced.
Embodiment 2
Fig. 4 illustrates the flowchart of the most OO caching read method.Such as Fig. 4 institute
Showing, the method specifically includes that
In step S401, in the case of receiving inquiry request, determine that inquiry please by general object query interface
Seek corresponding key.
Wherein, general object query interface can be the general-purpose interface of the object according to inquiry request inquiry class, for outside
Call.Call this general object query interface directly can inquire about from OO caching according to inquiry request and obtain right
As, the result that i.e. this general object query interface returns is object.This general object query interface supports the inquiry to any class.
In embodiments of the present invention, determine that key corresponding to inquiry request can be by general object query interface: pass through
General object query interface determines the querying condition that inquiry request is corresponding, and the map listing according to prestoring determines querying condition
Corresponding key.
In step S402, if finding the stream that key is corresponding, then according in advance by general object query interface from caching
If stream is deserialized as object by the parameter type that agreement specifies and parameter format, preset protocol can be used in the inverted sequence of any class
Rowization.
After determining, by general object query interface, the key that inquiry request is corresponding, by general object query interface root
Make a look up in the buffer based on hash algorithm according to key.
In embodiments of the present invention, the general default association of the unserializing that can be used in any class can be pre-designed
View, can call this preset protocol by general object query interface, to realize query object in the buffer.Due to without for every
Individual class separately designs agreement, thus greatly reduces development amount, improves exploitation convenience and development efficiency.
In step S403, by general object query interface returning an object value, to respond inquiry request.
In embodiments of the present invention, after stream being deserialized as object by general object query interface, general object
Object is supplied to external interface by query interface.
The embodiment of the present invention is by being encapsulated as general object by obtaining the process flowing and being deserialized as object from caching
Query interface, calls this general object query interface, directly can read the object of class in object oriented language from caching.
Fig. 5 illustrates showing of another flowchart of the most OO caching read method
It is intended to.As it is shown in figure 5, the method specifically includes that
In step S501, in the case of receiving inquiry request, determine that inquiry please by general object query interface
Seek corresponding key.
In step S502, if finding the stream that key is corresponding, then according in advance by general object query interface from caching
If stream is deserialized as object by the parameter type that agreement specifies and parameter format, preset protocol can be used in the inverted sequence of any class
Rowization.
In step S503, by general object query interface returning an object value, to respond inquiry request.
In step S504, if searching the stream corresponding less than key, then from outward by general object query interface from caching
The stream that in portion's storage device, key for searching is corresponding.
In step S505, if finding the stream that key is corresponding from External memory equipment, then according to preset protocol regulation
Stream is deserialized as object, and returning an object value by parameter type and parameter format, to respond inquiry request.
Fig. 6 illustrates in the most OO caching read method step S402 according to default association
Stream is deserialized as the schematic diagram implementing flow chart of object by the parameter type of view regulation and parameter format.Such as Fig. 6 institute
Showing, stream is deserialized as object by the parameter type and the parameter format that specify according to preset protocol, including:
In step s 601, from stream, obtain the information of preset protocol, and determine default association according to the information of preset protocol
The parameter type of view regulation and parameter format;
In step S602, all parameter classes in the parameter type specified according to preset protocol and parameter format, and stream
The parameter value of type, is deserialized as object by stream.
Wherein, the information of preset protocol can include the mark of preset protocol and the version number of preset protocol.According to presetting
The mark of agreement and the version number of preset protocol, it may be determined that parameter type that preset protocol specifies and parameter format, thus can
To determine all parameter types in stream and parameter format.
In a kind of possible implementation, parameter type includes: the name parameter of the class belonging to object, object whole
It is right that class belonging to Property Name parameter, whole property value parameters of object, the name parameter of all method of object, object creates
Whole property values ginseng of the class belonging to whole Property Name parameters of the class belonging to the name parameter of the method for elephant, object and object
Number etc..
So, by encapsulation general object query interface, the preset protocol of the unserializing that can be used in any class is set,
Object oriented language can be combined by OO caching read method according to embodiments of the present invention with caching, it is possible to logical
Cross the object that general object query interface realizes directly reading in object oriented language, thus greatly reduce development amount, carry
The portability of high exploitation and efficiency, and the read-write load of External memory equipment can be reduced, solve the read-write of External memory equipment
Energy bottleneck problem, thus it is greatly improved systematic function;The OO caching read method of the embodiment of the present invention is being applied
In the case of server end, the access speed of server can be greatly improved, support higher concurrently, thus same subscriber amount
Required number of servers is greatly reduced.
Embodiment 3
Fig. 7 illustrates the structured flowchart of the most OO caching writing station.This device can
Think server, it is also possible to cache writing station for other, in this no limit.For convenience of description, illustrate only and this
The part that bright embodiment is relevant.As it is shown in fig. 7, this device includes:
General object memory interface calling module 71, in the case of receiving write request, calls general object
Memory interface;
By general object memory interface, key generation module 72, for determining that object to be written that write request is corresponding is only
One identifier, and the key of object to be written is generated according to unique identifier;
Serialization module 73, for the parameter type specified according to preset protocol by general object memory interface and parameter
Form is written into object sequence and turns to stream, and preset protocol can be used in the serializing of any class;
Caching writing module 74, for caching stream write according to key by general object memory interface.
In a kind of possible implementation, device also includes:
External memory equipment writing module 75, for writing External memory equipment according to key by stream.
In a kind of possible implementation, serialization module 73 includes:
Parameter value determines submodule 731, for determining, by general object memory interface, all ginsengs that preset protocol specifies
Number types, and determine the parameter value of all parameter types that object to be written is corresponding;
Serializing submodule 732, for the parameter format specified according to preset protocol by general object memory interface, will
The parameter value of the information of preset protocol and all parameter types corresponding to object to be written is converted to stream.
In a kind of possible implementation, parameter type includes: the name parameter of the class belonging to object, object whole
It is right that class belonging to Property Name parameter, whole property value parameters of object, the name parameter of all method of object, object creates
Whole property values ginseng of the class belonging to whole Property Name parameters of the class belonging to the name parameter of the method for elephant, object and object
Number etc..
So, by encapsulation general object memory interface, the preset protocol of the serializing that can be used in any class, root are set
Object oriented language can be combined with caching according to the OO caching writing station of the embodiment of the present invention, it is possible to pass through
The general object memory interface of encapsulation realizes writing direct the object in object oriented language, thus greatly reduces development
Amount, improves portability and the efficiency of exploitation, and the read-write that can reduce External memory equipment loads, and solves the reading of External memory equipment
Write performance bottleneck problem, thus it is greatly improved systematic function;By the OO caching writing station of the embodiment of the present invention
In the case of being applied to server end, the access speed of server can be greatly improved, support higher concurrently, thus identical use
Number of servers required for the amount of family is greatly reduced.
Embodiment 4
Fig. 8 illustrates the structured flowchart of the most OO caching reading device.This device can
Think server, it is also possible to cache reading device for other, in this no limit.For convenience of description, illustrate only and this
The part that bright embodiment is relevant.As shown in Figure 8, this device includes:
Key determines module 81, in the case of receiving inquiry request, is determined by general object query interface and looks into
Ask the key that request is corresponding;
Unserializing module 82, if for finding the stream that key is corresponding, then by general object query interface from caching
Stream is deserialized as object by the parameter type specified according to preset protocol and parameter format, and preset protocol can be used in any class
Unserializing;
First inquiry response module 83, for by general object query interface returning an object value, to respond inquiry request.
In a kind of possible implementation, device also includes:
First searches module 84, if for searching the stream corresponding less than key by general object query interface from caching,
The stream that then key for searching is corresponding from External memory equipment;
Second inquiry response module 85, if for finding the stream that key is corresponding, then according to presetting from External memory equipment
Stream is deserialized as object, and returning an object value, to respond inquiry request by parameter type and parameter format that agreement specifies.
In a kind of possible implementation, unserializing module 82 includes:
Parameter type and form determine submodule 821, for obtaining the information of preset protocol from stream, and according to default association
The information of view determines the parameter type and parameter format that preset protocol specifies;
Unserializing submodule 822, for the parameter type specified according to preset protocol and parameter format, and institute in stream
There is the parameter value of parameter type, stream is deserialized as object.
In a kind of possible implementation, parameter type includes: the name parameter of the class belonging to object, object whole
It is right that class belonging to Property Name parameter, whole property value parameters of object, the name parameter of all method of object, object creates
Whole property values ginseng of the class belonging to whole Property Name parameters of the class belonging to the name parameter of the method for elephant, object and object
Number etc..
So, by encapsulation general object query interface, the preset protocol of the unserializing that can be used in any class is set,
Object oriented language can be combined by OO caching reading device according to embodiments of the present invention with caching, it is possible to logical
Cross the object that general object query interface realizes directly reading in object oriented language, thus greatly reduce development amount, carry
The portability of high exploitation and efficiency, and the read-write load of External memory equipment can be reduced, solve the read-write of External memory equipment
Energy bottleneck problem, thus it is greatly improved systematic function;The OO caching reading device of the embodiment of the present invention is being applied
In the case of server end, the access speed of server can be greatly improved, support higher concurrently, thus same subscriber amount
Required number of servers is greatly reduced.
Embodiment 5
Fig. 9 shows the exemplary of a kind of OO caching writing station of an alternative embodiment of the invention
Structured flowchart.Described OO caching writing station 1100 can be to possess the host server of computing capability, Ge Renji
Calculation machine PC or portable portable computer or terminal etc..The specific embodiment of the invention is to calculating the concrete of node
Realization limits.
Described OO caching writing station 1100 includes processor (processor) 1110, communication interface
(Communications Interface) 1120, memorizer (memory) 1130 and bus 1140.Wherein, processor 1110,
Communication interface 1120 and memorizer 1130 complete mutual communication by bus 1140.
Communication interface 1120 is used for and network device communications, and wherein the network equipment includes such as Virtual Machine Manager center, is total to
Enjoy storage etc..
Processor 1110 is used for performing program.Processor 1110 is probably a central processor CPU, or special collection
Become circuit ASIC (Application Specific Integrated Circuit), or be configured to implement the present invention
One or more integrated circuits of embodiment.
Memorizer 1130 is used for depositing file.Memorizer 1130 may comprise high-speed RAM memorizer, it is also possible to also includes non-
Volatile memory (non-volatile memory), for example, at least one disk memory.Memorizer 1130 can also be to deposit
Memory array.Memorizer 1130 is also possible to by piecemeal, and described piece can be by certain rule sets synthesis virtual volume.
In a kind of possible embodiment, said procedure can be the program code including computer-managed instruction.This journey
Sequence specifically can comprise for performing the following instruction operated:
In the case of receiving write request, call general object memory interface;
The unique identifier of the object to be written of said write request correspondence is determined by described general object memory interface,
And the key of described object to be written is generated according to described unique identifier;
The parameter type and the parameter format that are specified according to preset protocol by described general object memory interface are treated described
Write object sequence turns to stream, and described preset protocol can be used in the serializing of any class;
By described general object memory interface according to described key by described stream write caching.
Assume above-mentioned for the first possible embodiment, then provide based on the embodiment that the first is possible
The possible embodiment of the second in, this program also can comprise for performing the following instruction operated:
After described stream write being cached according to described key by described general object memory interface, will according to described key
Described stream write External memory equipment.
In the third the possible embodiment provided based on the embodiment that the first is possible, this program is also
Can comprise for performing the following instruction operated:
The parameter type and the parameter format that are specified according to preset protocol by described general object memory interface are treated described
Write object sequence turns to stream, including:
Determine, by described general object memory interface, all described parameter type that described preset protocol specifies, and determine
The parameter value of all described parameter type that described object to be written is corresponding;
The described parameter format specified according to described preset protocol by described general object memory interface, is preset described
The parameter value of the information of agreement and all described parameter type corresponding to described object to be written is converted to stream.
The first, based on the second or the third possible embodiment and the 4th kind of possible enforcement provided
In mode, this program also can comprise for performing the following instruction operated:
Described parameter type includes: the name parameter of the class belonging to object, whole Property Name parameters of described object, institute
State the class belonging to the name parameter of all method of whole property value parameters of object, described object, described object and create described
Class belonging to whole Property Name parameters of the class belonging to the name parameter of the method for object, described object and described object complete
Subordinate's property value parameter.
Embodiment 6
Figure 10 shows the exemplary of a kind of OO caching reading device of an alternative embodiment of the invention
Structured flowchart.Described OO caching reading device 1200 can be to possess the host server of computing capability, individual
Computer PC or portable portable computer or terminal etc..The specific embodiment of the invention is not to the tool calculating node
Body realizes limiting.
Described OO caching reading device 1200 includes processor 1210, communication interface 1220, memorizer 1230
With bus 1240.Wherein, processor 1210, communication interface 1220 and memorizer 1230 are completed by bus 1240 each other
Communication.
Communication interface 1220 is used for and network device communications, and wherein the network equipment includes such as Virtual Machine Manager center, is total to
Enjoy storage etc..
Processor 1210 is used for performing program.Processor 1210 is probably a central processor CPU, or special collection
Become circuit ASIC, or be configured to implement one or more integrated circuits of the embodiment of the present invention.
Memorizer 1230 is used for depositing file.Memorizer 1230 may comprise high-speed RAM memorizer, it is also possible to also includes non-
Volatile memory, for example, at least one disk memory.Memorizer 1230 can also be memory array.Memorizer 1230 is also
May be by piecemeal, and described piece can be by certain rule sets synthesis virtual volume.
In a kind of possible embodiment, said procedure can be the program code including computer-managed instruction.This journey
Sequence specifically can comprise for performing the following instruction operated:
In the case of receiving inquiry request, determine that described inquiry request is corresponding by general object query interface
Key;
If finding, by described general object query interface, the stream that described key is corresponding from described caching, then according to presetting
Described stream is deserialized as object by parameter type and parameter format that agreement specifies, and described preset protocol can be used in any class
Unserializing;
Described object is returned, to respond described inquiry request by described general object query interface.
Assume above-mentioned for the first possible embodiment, then provide based on the embodiment that the first is possible
The possible embodiment of the second in, this program also can comprise for performing the following instruction operated:
After determining, by general object query interface, the key that described inquiry request is corresponding, if by described general object
Query interface searches the stream corresponding less than described key from described caching, then search described key from External memory equipment corresponding
Stream;
If finding the stream that described key is corresponding from described External memory equipment, then the institute specified according to described preset protocol
State parameter type and described parameter format and described stream is deserialized as described object, and return described object, described with response
Inquiry request.
Based on the embodiment that the first or the second are possible and in the 4th kind of possible embodiment provided,
This program also can comprise for performing the following instruction operated:
Described stream is deserialized as object by the parameter type and the parameter format that specify according to preset protocol, including:
From described stream, obtain the information of described preset protocol, and determine described presetting according to the information of described preset protocol
The described parameter type of agreement regulation and described parameter format;
In the described parameter type specified according to described preset protocol and described parameter format, and described stream all described
The parameter value of parameter type, is deserialized as described object by described stream.
Based on the embodiment that the first or the second are possible and in the 4th kind of possible embodiment provided,
This program also can comprise for performing the following instruction operated:
Described parameter type includes: the name parameter of the class belonging to object, whole Property Name parameters of described object, institute
State the class belonging to the name parameter of all method of whole property value parameters of object, described object, described object and create described
Class belonging to whole Property Name parameters of the class belonging to the name parameter of the method for object, described object and described object complete
Subordinate's property value parameter.
Those of ordinary skill in the art are it is to be appreciated that each example modules in embodiment described herein and algorithm
Step, it is possible to being implemented in combination in of electronic hardware or computer software and electronic hardware.These functions are actually with hardware also
It is that software form realizes, depends on application-specific and the design constraint of technical scheme.Professional and technical personnel can be for
Specific application selects different methods to realize described function, but this realization is it is not considered that exceed the model of the present invention
Enclose.
If using the form of computer software realize described function and as independent production marketing or use time, then exist
To a certain extent it is believed that all or part of (part such as contributed prior art) of technical scheme is
Embody in form of a computer software product.This computer software product is generally stored inside the non-volatile of embodied on computer readable
In storage medium, including some instructions with so that computer equipment (can be that personal computer, server or network set
Standby etc.) perform all or part of step of various embodiments of the present invention method.And aforesaid storage medium include USB flash disk, portable hard drive,
Read only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic
The various medium that can store program code such as dish or CD.
The above, the only detailed description of the invention of the present invention, but protection scope of the present invention is not limited thereto, and any
Those familiar with the art, in the technical scope that the invention discloses, can readily occur in change or replace, should contain
Cover within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with described scope of the claims.