[go: up one dir, main page]

CN106095698A - OO caching write, read method and device - Google Patents

OO caching write, read method and device Download PDF

Info

Publication number
CN106095698A
CN106095698A CN201610391139.2A CN201610391139A CN106095698A CN 106095698 A CN106095698 A CN 106095698A CN 201610391139 A CN201610391139 A CN 201610391139A CN 106095698 A CN106095698 A CN 106095698A
Authority
CN
China
Prior art keywords
parameter
stream
preset protocol
key
class
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.)
Granted
Application number
CN201610391139.2A
Other languages
Chinese (zh)
Other versions
CN106095698B (en
Inventor
王军
吴昊宇
王冀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba China Co Ltd
Youku Network Technology Beijing Co Ltd
Original Assignee
1Verge Internet Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 1Verge Internet Technology Beijing Co Ltd filed Critical 1Verge Internet Technology Beijing Co Ltd
Priority to CN201610391139.2A priority Critical patent/CN106095698B/en
Publication of CN106095698A publication Critical patent/CN106095698A/en
Application granted granted Critical
Publication of CN106095698B publication Critical patent/CN106095698B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0877Cache access modes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及面向对象的缓存写入、读取方法及装置。该面向对象的缓存写入方法包括:在接收到写入请求的情况下,调用通用对象存储接口;通过通用对象存储接口确定写入请求对应的待写入对象的唯一标识符,并根据唯一标识符生成待写入对象的键;通过通用对象存储接口按照预设协议规定的参数类型和参数格式将待写入对象序列化为流,预设协议能够用于任意类的序列化;通过通用对象存储接口根据键将流写入缓存。根据本发明能够将面向对象语言与缓存相结合,实现直接存取面向对象语言中的对象,从而大大减少开发工作量,提高开发的便携性和效率,并能降低外部存储设备的读写负载,解决外部存储设备的读写性能瓶颈问题,从而大大提高系统性能。

The invention relates to an object-oriented cache writing and reading method and device. The object-oriented cache write method includes: when a write request is received, calling a general object storage interface; determining the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and character to generate the key of the object to be written; serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class; through the general object The storage interface writes the stream to the cache based on the key. According to the present invention, the object-oriented language and the cache can be combined to realize direct access to objects in the object-oriented language, thereby greatly reducing the development workload, improving the portability and efficiency of development, and reducing the read and write load of the external storage device. Solve the bottleneck problem of read and write performance of external storage devices, thereby greatly improving system performance.

Description

面向对象的缓存写入、读取方法及装置Object-oriented cache writing and reading method and device

技术领域technical field

本发明涉及缓存技术领域,尤其涉及一种面向对象的缓存写入、读取方法及装置。The invention relates to the technical field of caching, in particular to an object-oriented caching writing and reading method and device.

背景技术Background technique

对于大规模Web(网页)系统,用户数量非常大,导致服务器的负载非常高,因此磁盘读写性能低下,需要使用内存作为缓存来提高整个系统的性能。缓存可以直接向大多数用户提供服务,避免用户的每个请求都访问性能低下的外部存储设备,从而提高了整个系统的效率。因此,缓存对于提高整个系统的性能是极为重要的。For a large-scale Web (web page) system, the number of users is very large, resulting in a very high load on the server, so the disk read and write performance is low, and memory needs to be used as a cache to improve the performance of the entire system. The cache can directly provide services to most users, avoiding each request of users from accessing low-performance external storage devices, thereby improving the efficiency of the entire system. Therefore, caching is extremely important to improve the performance of the entire system.

现有的大规模Web系统通常使用面向对象语言进行开发。面向对象是一种软件开发方法,指的是在程序设计中采用封装、继承和多态等设计方法。封装是指将现实世界中存在的某个客体的属性与行为绑定在一起,并放置在一个逻辑单元内。该逻辑单元负责将所描述的属性隐藏起来,外界对客体内部属性的所有访问只能通过提供的用户接口实现。这样做既可以起到对客体属性的保护作用,又可以提高软件系统的可维护性。对象是人们要进行研究的任何事物,从简单的整数到复杂的飞机等均可看作对象,它不仅能表示具体的事物,还能表示抽象的规则、计划或事件。对象具有状态,一个对象用数据值来描述它的状态。对象还有操作,用于改变对象的状态,对象及其操作就是对象的行为。对象实现了数据和操作的结合,使数据和操作封装于对象的统一体中。类是具有相同特性和行为的对象的抽象。因此,类是对象的抽象,对象是类的具体化,也可以说,对象是类的实例。类实际上是一种数据类型。例如,鹦鹉可以视为一种类,而具体的一只鹦鹉可以视为一个对象。类具有属性,它是对象的状态的抽象,类的属性用数据结构来描述。类具有操作,它是对象的行为的抽象,用操作名和实现该操作的方法来描述。Existing large-scale Web systems are usually developed using object-oriented languages. Object-oriented is a software development method, which refers to the use of encapsulation, inheritance and polymorphism in program design. Encapsulation refers to binding the properties and behavior of an object existing in the real world together and placing them in a logical unit. This logical unit is responsible for hiding the described attributes, and all access to the internal attributes of the object can only be realized through the provided user interface. Doing so can not only protect the object attributes, but also improve the maintainability of the software system. An object is anything that people want to study, ranging from simple integers to complex airplanes. It can not only represent specific things, but also represent abstract rules, plans or events. Objects have state, and an object uses data values to describe its state. Objects also have operations, which are used to change the state of the object, and the object and its operations are the behavior of the object. The object realizes the combination of data and operation, so that the data and operation are encapsulated in the unity of the object. A class is an abstraction of objects with the same characteristics and behavior. Therefore, a class is an abstraction of an object, and an object is the embodiment of a class. It can also be said that an object is an instance of a class. A class is actually a data type. For example, a parrot can be considered a class, and a specific parrot can be considered an object. A class has attributes, which are an abstraction of the state of an object, and the attributes of a class are described by a data structure. A class has an operation, which is an abstraction of the behavior of an object, described by the name of the operation and the method that implements the operation.

缓存指的是数据交换的缓冲区,当某一硬件要读取数据时,会首先从缓存中查找需要的数据,如果找到了则直接执行,找不到的话则从下一级存储设备中查找。由于缓存的读写速度比下一级存储设备快得多,因此缓存能够帮助整个系统更快地运行。缓存工作的原理即“引用的局部性”,包括时间局部性和空间局部性。时间局部性是指当某个数据被访问过一次之后,过不了多长时间就会被再一次访问;空间局部性是指CPU(CentralProcessing Unit,中央处理器)在某一时刻需要某个数据,那么很可能下一步就需要其附近的数据。对于应用程序而言,不管是指令流还是数据流都会出现引用的局部性现象。由于计算机的内存的读写速度远远快于硬盘的读写速度,因此可以将从硬盘读取到的数据暂时存放在内存里,之后使用该数据的时候就不用再次从硬盘中读取了,这样就大大提高了整体的读写速度,这个过程就是基于前述的引用的局部性原理把内存作为硬盘的缓存使用。Cache refers to the buffer for data exchange. When a piece of hardware wants to read data, it will first search for the required data from the cache. If it finds it, it will execute it directly. If it cannot find it, it will search it from the next-level storage device. . Since the cache reads and writes much faster than the next-level storage device, the cache can help the entire system run faster. The working principle of caching is "locality of reference", including temporal locality and spatial locality. Time locality means that after a certain data is accessed once, it will be accessed again in a short time; spatial locality means that the CPU (Central Processing Unit, central processing unit) needs a certain data at a certain moment, Then it is likely that the next step will need data near it. For the application program, the locality of reference phenomenon will appear in both the instruction flow and the data flow. Since the reading and writing speed of the computer's memory is much faster than that of the hard disk, the data read from the hard disk can be temporarily stored in the memory, and there is no need to read from the hard disk again when using the data later. In this way, the overall reading and writing speed is greatly improved. This process is based on the locality principle cited above to use the memory as a hard disk cache.

现有的大规模Web系统通常使用面向对象语言进行开发,但目前的缓存技术无法很好地适应面向对象系统的开发需求。具体而言,目前在面向对象系统中使用缓存技术时,协议在各个类之间无法通用,研发人员需要为每个类分别设计序列化和反序列化协议,以及针对每个类分别进行开发和调试,导致耗费大量时间,且容易出错,整个过程效率低下。Existing large-scale Web systems are usually developed using object-oriented languages, but the current caching technology cannot well meet the development needs of object-oriented systems. Specifically, when using caching technology in an object-oriented system, the protocol cannot be used universally among various classes, and developers need to design serialization and deserialization protocols for each class, and develop and deserialize each class separately. Debugging, resulting in a lot of time-consuming, error-prone, and low efficiency of the entire process.

发明内容Contents of the invention

技术问题technical problem

有鉴于此,本发明要解决的技术问题是,现有的缓存技术在面向对象系统中的适应性较差,导致开发效率较低。In view of this, the technical problem to be solved by the present invention is that the existing caching technology has poor adaptability in object-oriented systems, resulting in low development efficiency.

解决方案solution

为了解决上述技术问题,根据本发明的一实施例,提供了一种面向对象的缓存写入方法,包括:In order to solve the above technical problems, according to an embodiment of the present invention, an object-oriented cache writing method is provided, including:

在接收到写入请求的情况下,调用通用对象存储接口;In the case of receiving a write request, call the general object storage interface;

通过所述通用对象存储接口确定所述写入请求对应的待写入对象的唯一标识符,并根据所述唯一标识符生成所述待写入对象的键;Determine the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and generate a key of the object to be written according to the unique identifier;

通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,所述预设协议能够用于任意类的序列化;Serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class;

通过所述通用对象存储接口根据所述键将所述流写入缓存。Writing the stream into the cache according to the key through the common object storage interface.

对于上述方法,在一种可能的实现方式中,在通过所述通用对象存储接口根据所述键将所述流写入缓存之后,所述方法还包括:For the above method, in a possible implementation manner, after writing the stream into the cache according to the key through the general object storage interface, the method further includes:

根据所述键将所述流写入外部存储设备。Write the stream to external storage according to the key.

对于上述方法,在一种可能的实现方式中,通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,包括:For the above method, in a possible implementation manner, the object to be written is serialized into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, including:

通过所述通用对象存储接口确定所述预设协议规定的所有所述参数类型,并确定所述待写入对象对应的所有所述参数类型的参数值;determining all the parameter types specified in the preset protocol through the general object storage interface, and determining parameter values of all the parameter types corresponding to the object to be written;

通过所述通用对象存储接口按照所述预设协议规定的所述参数格式,将所述预设协议的信息以及所述待写入对象对应的所有所述参数类型的参数值转换为流。Converting information of the preset protocol and parameter values of all parameter types corresponding to the object to be written into a stream through the general object storage interface according to the parameter format specified in the preset protocol.

对于上述方法,在一种可能的实现方式中,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。For the above method, in a possible implementation manner, the parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, all The name parameter of the method, the name parameter of the method of creating the object of the class to which the object belongs, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs.

为了解决上述技术问题,根据本发明的另一实施例,提供了一种面向对象的缓存读取方法,包括:In order to solve the above technical problems, according to another embodiment of the present invention, an object-oriented cache reading method is provided, including:

在接收到查询请求的情况下,通过通用对象查询接口确定所述查询请求对应的键;In the case of receiving a query request, determine the key corresponding to the query request through the general object query interface;

若通过所述通用对象查询接口从所述缓存中查找到所述键对应的流,则按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,所述预设协议能够用于任意类的反序列化;If the stream corresponding to the key is found from the cache through the general object query interface, deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can for deserialization of arbitrary classes;

通过所述通用对象查询接口返回所述对象,以响应所述查询请求。Returning the object through the general object query interface to respond to the query request.

对于上述方法,在一种可能的实现方式中,在通过通用对象查询接口确定所述查询请求对应的键之后,所述方法还包括:For the above method, in a possible implementation manner, after determining the key corresponding to the query request through the general object query interface, the method further includes:

若通过所述通用对象查询接口从所述缓存中查找不到所述键对应的流,则从外部存储设备中查找所述键对应的流;If the stream corresponding to the key cannot be found from the cache through the general object query interface, then search for the stream corresponding to the key from an external storage device;

若从所述外部存储设备中查找到所述键对应的流,则按照所述预设协议规定的所述参数类型和所述参数格式将所述流反序列化为所述对象,并返回所述对象,以响应所述查询请求。If the stream corresponding to the key is found from the external storage device, deserialize the stream into the object according to the parameter type and the parameter format stipulated in the preset protocol, and return the said object in response to said query request.

对于上述方法,在一种可能的实现方式中,按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,包括:For the above method, in a possible implementation, the stream is deserialized into an object according to the parameter type and parameter format specified in the preset protocol, including:

从所述流中获取所述预设协议的信息,并根据所述预设协议的信息确定所述预设协议规定的所述参数类型和所述参数格式;Obtaining the information of the preset protocol from the stream, and determining the parameter type and the parameter format specified in the preset protocol according to the information of the preset protocol;

根据所述预设协议规定的所述参数类型和所述参数格式,以及所述流中所有所述参数类型的参数值,将所述流反序列化为所述对象。Deserialize the stream into the object according to the parameter type and the parameter format specified in the preset protocol, and all parameter values of the parameter type in the stream.

对于上述方法,在一种可能的实现方式中,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。For the above method, in a possible implementation manner, the parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, all The name parameter of the method, the name parameter of the method of creating the object of the class to which the object belongs, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs.

为了解决上述技术问题,根据本发明的另一实施例,提供了一种面向对象的缓存写入装置,包括:In order to solve the above technical problems, according to another embodiment of the present invention, an object-oriented cache writing device is provided, including:

通用对象存储接口调用模块,用于在接收到写入请求的情况下,调用通用对象存储接口;A generic object storage interface calling module, configured to call the generic object storage interface when a write request is received;

键生成模块,用于通过所述通用对象存储接口确定所述写入请求对应的待写入对象的唯一标识符,并根据所述唯一标识符生成所述待写入对象的键;A key generation module, configured to determine the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and generate the key of the object to be written according to the unique identifier;

序列化模块,用于通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,所述预设协议能够用于任意类的序列化;A serialization module, configured to serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class;

缓存写入模块,用于通过所述通用对象存储接口根据所述键将所述流写入缓存。A cache writing module, configured to write the stream into the cache according to the key through the common object storage interface.

对于上述装置,在一种可能的实现方式中,所述装置还包括:For the above device, in a possible implementation manner, the device further includes:

外部存储设备写入模块,用于根据所述键将所述流写入外部存储设备。An external storage device writing module, configured to write the stream into an external storage device according to the key.

对于上述装置,在一种可能的实现方式中,所述序列化模块包括:For the above device, in a possible implementation manner, the serialization module includes:

参数值确定子模块,用于通过所述通用对象存储接口确定所述预设协议规定的所有所述参数类型,并确定所述待写入对象对应的所有所述参数类型的参数值;A parameter value determining submodule, configured to determine all the parameter types specified in the preset protocol through the general object storage interface, and determine parameter values of all the parameter types corresponding to the object to be written;

序列化子模块,用于通过所述通用对象存储接口按照所述预设协议规定的所述参数格式,将所述预设协议的信息以及所述待写入对象对应的所有所述参数类型的参数值转换为流。The serialization submodule is used to store the information of the preset protocol and all the parameter types corresponding to the object to be written according to the parameter format stipulated in the preset protocol through the general object storage interface The parameter value is converted to a stream.

对于上述装置,在一种可能的实现方式中,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。For the above device, in a possible implementation manner, the parameter type includes: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, all The name parameter of the method, the name parameter of the method of creating the object of the class to which the object belongs, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs.

为了解决上述技术问题,根据本发明的另一实施例,提供了一种面向对象的缓存读取装置,包括:In order to solve the above technical problems, according to another embodiment of the present invention, an object-oriented cache reading device is provided, including:

键确定模块,用于在接收到查询请求的情况下,通过通用对象查询接口确定所述查询请求对应的键;A key determination module, configured to determine the key corresponding to the query request through the general object query interface when the query request is received;

反序列化模块,用于若通过所述通用对象查询接口从所述缓存中查找到所述键对应的流,则按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,所述预设协议能够用于任意类的反序列化;A deserialization module, configured to deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol if the stream corresponding to the key is found from the cache through the general object query interface , the preset protocol can be used for deserialization of any class;

第一查询响应模块,用于通过所述通用对象查询接口返回所述对象,以响应所述查询请求。The first query response module is configured to return the object through the general object query interface to respond to the query request.

对于上述装置,在一种可能的实现方式中,所述装置还包括:For the above device, in a possible implementation manner, the device further includes:

第一查找模块,用于若通过所述通用对象查询接口从所述缓存中查找不到所述键对应的流,则从外部存储设备中查找所述键对应的流;A first search module, configured to search for the stream corresponding to the key from an external storage device if the stream corresponding to the key cannot be found from the cache through the general object query interface;

第二查询响应模块,用于若从所述外部存储设备中查找到所述键对应的流,则按照所述预设协议规定的所述参数类型和所述参数格式将所述流反序列化为所述对象,并返回所述对象,以响应所述查询请求。The second query response module is configured to deserialize the stream according to the parameter type and the parameter format stipulated in the preset protocol if the stream corresponding to the key is found from the external storage device for the object and return the object in response to the query request.

对于上述装置,在一种可能的实现方式中,所述反序列化模块包括:For the above device, in a possible implementation manner, the deserialization module includes:

参数类型和格式确定子模块,用于从所述流中获取所述预设协议的信息,并根据所述预设协议的信息确定所述预设协议规定的所述参数类型和所述参数格式;A parameter type and format determining submodule, configured to obtain information of the preset protocol from the stream, and determine the parameter type and the parameter format specified in the preset protocol according to the information of the preset protocol ;

反序列化子模块,用于根据所述预设协议规定的所述参数类型和所述参数格式,以及所述流中所有所述参数类型的参数值,将所述流反序列化为所述对象。The deserialization submodule is used to deserialize the stream into the object.

对于上述装置,在一种可能的实现方式中,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。For the above device, in a possible implementation manner, the parameter type includes: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, all The name parameter of the method, the name parameter of the method of creating the object of the class to which the object belongs, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs.

有益效果Beneficial effect

通过封装通用对象存储接口和通用对象查询接口,设置能够用于任意类的序列化和反序列化的预设协议,根据本发明实施例的面向对象的缓存写入方法、读取方法及装置能够将面向对象语言与缓存相结合,能够通过封装的通用对象存储接口和通用对象查询接口实现直接存取面向对象语言中的对象,从而大大减少开发工作量,提高开发的便携性和效率,并能降低外部存储设备的读写负载,解决外部存储设备的读写性能瓶颈问题,从而大大提高系统性能;在将本发明实施例的面向对象的缓存写入方法、读取方法及装置应用于服务器端的情况下,可以大大提高服务器的访问速度,支持更高的并发,从而相同用户量所需要的服务器数量大大减小。By encapsulating the general object storage interface and the general object query interface, setting a preset protocol that can be used for serialization and deserialization of any class, the object-oriented cache writing method, reading method and device according to the embodiment of the present invention can Combining the object-oriented language with the cache, the objects in the object-oriented language can be directly accessed through the encapsulated general object storage interface and general object query interface, thereby greatly reducing the development workload, improving the portability and efficiency of development, and enabling Reduce the read and write load of the external storage device, solve the bottleneck problem of the read and write performance of the external storage device, thereby greatly improving the system performance; when the object-oriented cache writing method, reading method and device of the embodiment of the present invention are applied to the server Under certain circumstances, the access speed of the server can be greatly improved, and higher concurrency can be supported, so that the number of servers required for the same amount of users is greatly reduced.

根据下面参考附图对示例性实施例的详细说明,本发明的其它特征及方面将变得清楚。Other features and aspects of the present invention will become apparent from the following detailed description of exemplary embodiments with reference to the accompanying drawings.

附图说明Description of drawings

包含在说明书中并且构成说明书的一部分的附图与说明书一起示出了本发明的示例性实施例、特征和方面,并且用于解释本发明的原理。The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the invention and together with the description, serve to explain the principles of the invention.

图1示出根据本发明一实施例的面向对象的缓存写入方法的实现流程图;FIG. 1 shows a flowchart of an implementation of an object-oriented cache writing method according to an embodiment of the present invention;

图2示出根据本发明一实施例的面向对象的缓存写入方法的另一实现流程图的示意图;FIG. 2 shows a schematic diagram of another implementation flowchart of an object-oriented cache writing method according to an embodiment of the present invention;

图3示出根据本发明一实施例的面向对象的缓存写入方法步骤S103的具体实现流程图的示意图;FIG. 3 shows a schematic diagram of a specific implementation flowchart of step S103 of an object-oriented cache writing method according to an embodiment of the present invention;

图4示出根据本发明一实施例的面向对象的缓存读取方法的实现流程图;FIG. 4 shows an implementation flowchart of an object-oriented cache reading method according to an embodiment of the present invention;

图5示出根据本发明一实施例的面向对象的缓存读取方法的另一实现流程图的示意图;FIG. 5 shows a schematic diagram of another implementation flowchart of an object-oriented cache reading method according to an embodiment of the present invention;

图6示出根据本发明一实施例的面向对象的缓存读取方法步骤S402中按照预设协议规定的参数类型和参数格式将流反序列化为对象的具体实现流程图的示意图;FIG. 6 shows a schematic diagram of a specific implementation flowchart of deserializing a stream into an object according to the parameter type and parameter format specified in the preset protocol in step S402 of the object-oriented cache reading method according to an embodiment of the present invention;

图7示出根据本发明一实施例的面向对象的缓存写入装置的结构框图;FIG. 7 shows a structural block diagram of an object-oriented cache writing device according to an embodiment of the present invention;

图8示出根据本发明一实施例的面向对象的缓存读取装置的结构框图;FIG. 8 shows a structural block diagram of an object-oriented cache reading device according to an embodiment of the present invention;

图9示出根据本发明一实施例的面向对象的缓存写入装置的一示例性的结构框图;FIG. 9 shows an exemplary structural block diagram of an object-oriented cache writing device according to an embodiment of the present invention;

图10示出根据本发明一实施例的面向对象的缓存读取装置的一示例性的结构框图。Fig. 10 shows an exemplary structural block diagram of an object-oriented cache reading device according to an embodiment of the present invention.

具体实施方式detailed description

以下将参考附图详细说明本发明的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。Various exemplary embodiments, features, and aspects of the invention will be described in detail below with reference to the accompanying drawings. The same reference numbers in the figures indicate functionally identical or similar elements. While various aspects of the embodiments are shown in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.

在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior or better than other embodiments.

另外,为了更好的说明本发明,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本发明同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本发明的主旨。In addition, in order to better illustrate the present invention, numerous specific details are given in the specific embodiments below. It will be understood by those skilled in the art that the present invention may be practiced without certain of the specific details. In some instances, methods, means, components and circuits well known to those skilled in the art have not been described in detail in order to highlight the gist of the present invention.

实施例1Example 1

图1示出根据本发明一实施例的面向对象的缓存写入方法的实现流程图。如图1所示,该方法主要包括:FIG. 1 shows a flowchart of an implementation of an object-oriented cache writing method according to an embodiment of the present invention. As shown in Figure 1, the method mainly includes:

在步骤S101中,在接收到写入请求的情况下,调用通用对象存储接口。In step S101, when a write request is received, a common object storage interface is invoked.

需要说明的是,本发明实施例可以适用于基于面向对象语言开发的任何系统中,例如可以应用于网站的后台服务器中。It should be noted that the embodiment of the present invention can be applied to any system developed based on object-oriented language, for example, it can be applied to a background server of a website.

其中,通用对象存储接口可以为用于存储类的对象的通用接口,供外部调用。调用该通用对象存储接口可以直接向面向对象系统的缓存中写入任意类的对象。Wherein, the general object storage interface may be a general interface for storing objects of a class for external calling. Calling this common object storage interface can directly write objects of any class into the cache of the object-oriented system.

在本发明实施例中,在外部接口接收到写入请求的情况下,外部接口调用通用对象存储接口,以使通用对象存储接口向缓存中写入该写入请求对应的待写入对象。In the embodiment of the present invention, when the external interface receives a write request, the external interface calls the general object storage interface, so that the general object storage interface writes the object to be written corresponding to the write request into the cache.

在步骤S102中,通过通用对象存储接口确定写入请求对应的待写入对象的唯一标识符,并根据唯一标识符生成待写入对象的键。In step S102, the unique identifier of the object to be written corresponding to the write request is determined through the common object storage interface, and a key of the object to be written is generated according to the unique identifier.

其中,待写入对象的唯一标识符可以包括待写入对象的一种属性名称和该属性名称对应的属性值,根据该属性值可以唯一确定该待写入对象,由此该唯一标识符可以作为存取标记。根据唯一标识符生成待写入对象的键可以为:将唯一标识符转换得到的字符串作为待写入对象的键。Wherein, the unique identifier of the object to be written can include an attribute name of the object to be written and the attribute value corresponding to the attribute name, and the object to be written can be uniquely determined according to the attribute value, so that the unique identifier can be as an access token. Generating the key of the object to be written according to the unique identifier may be: using the character string obtained by converting the unique identifier as the key of the object to be written.

在步骤S103中,通过通用对象存储接口按照预设协议规定的参数类型和参数格式将待写入对象序列化为流,预设协议能够用于任意类的序列化。In step S103, the object to be written is serialized into a stream through the universal object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class.

其中,流可以为字节流或者字符流,在此不作限定。字节流是由字节组成的,字符流是由字符组成的。在本发明实施例中,字节流可以指将待写入对象按照预设协议封装成一系列连续字节;字符流可以指将待写入对象按照预设协议封装成一系列连续字符。类可以为任意一个面向对象语言定义的类,对象是类的实例。Wherein, the stream may be a byte stream or a character stream, which is not limited here. A byte stream is composed of bytes, and a character stream is composed of characters. In the embodiment of the present invention, the byte stream may refer to encapsulating the object to be written into a series of continuous bytes according to a preset protocol; the character stream may refer to encapsulating the object to be written into a series of continuous characters according to a preset protocol. A class can be any class defined in an object-oriented language, and an object is an instance of a class.

在本发明实施例中,可以预先设计能够用于任意类的序列化的通用的预设协议,通过通用对象存储接口可以调用该预设协议,以实现在缓存中写入对象。由于无需为每个类分别设计协议,从而大大减少了开发工作量,提高了开发便捷性及开发效率。In the embodiment of the present invention, a general preset protocol that can be used for serialization of any class can be pre-designed, and the preset protocol can be called through a general object storage interface to implement writing objects in the cache. Since there is no need to design protocols for each class separately, the development workload is greatly reduced, and the convenience and efficiency of development are improved.

在步骤S104中,通过通用对象存储接口根据键将流写入缓存。In step S104, the stream is written into the cache according to the key through the common object storage interface.

在本发明实施例中,缓存可以使用内存作为存储设备。缓存可以采用键值对的存储方式,可以使用散列表作为数据结构,键可以是一个任意的字符串,值也可以是一个任意的字符串,一个键对应一个值。散列表可以根据键确定值的存储位置,从而实现了常数级的查找、更新和删除。在本发明实施例中,键值对中的值可以指流。In this embodiment of the present invention, the cache may use memory as a storage device. The cache can be stored in a key-value pair, and a hash table can be used as a data structure. The key can be an arbitrary string, and the value can also be an arbitrary string. A key corresponds to a value. The hash table can determine the storage location of the value according to the key, thus realizing constant level search, update and deletion. In this embodiment of the present invention, the value in the key-value pair may refer to a stream.

其中,步骤S104具体可以为:通过通用对象存储接口根据键基于哈希算法将流写入缓存。Wherein, step S104 may specifically be: write the stream into the cache based on the hash algorithm based on the key through the common object storage interface.

本发明实施例将向缓存写入对象的过程封装为通用对象存储接口,调用该通用对象存储接口,可以直接将面向对象语言中的类的对象写入缓存中。The embodiment of the present invention encapsulates the process of writing objects into the cache as a general object storage interface, and calling the general object storage interface can directly write objects of classes in an object-oriented language into the cache.

在一种可能的实现方式在,在步骤S101之前,该方法还包括:将类实例化,产生待写入对象,并根据该类定义的各个属性对该待写入对象进行赋值。In a possible implementation manner, before step S101, the method further includes: instantiating the class, generating an object to be written, and assigning values to the object to be written according to each attribute defined by the class.

图2示出根据本发明一实施例的面向对象的缓存写入方法的另一实现流程图的示意图。如图2所示,该方法主要包括:FIG. 2 shows a schematic diagram of another implementation flowchart of an object-oriented cache writing method according to an embodiment of the present invention. As shown in Figure 2, the method mainly includes:

在步骤S201中,在接收到写入请求的情况下,调用通用对象存储接口;In step S201, in the case of receiving a write request, call the common object storage interface;

在步骤S202中,通过通用对象存储接口确定写入请求对应的待写入对象的唯一标识符,并根据唯一标识符生成待写入对象的键;In step S202, determine the unique identifier of the object to be written corresponding to the write request through the common object storage interface, and generate the key of the object to be written according to the unique identifier;

在步骤S203中,通过通用对象存储接口按照预设协议规定的参数类型和参数格式将待写入对象序列化为流,预设协议能够用于任意类的序列化;In step S203, serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class;

在步骤S204中,通过通用对象存储接口根据键将流写入缓存;In step S204, the stream is written into the cache according to the key through the common object storage interface;

在步骤S205中,根据键将流写入外部存储设备。In step S205, the stream is written to the external storage device according to the key.

在一种可能的实现方式中,在通过通用对象存储接口根据键将流写入缓存后,根据键将流写入外部存储设备。在这里,外部存储设备可以为硬盘,在此不作限定。外部存储设备用于永久性存储数据。In a possible implementation manner, after the stream is written into the cache according to the key through the common object storage interface, the stream is written into the external storage device according to the key. Here, the external storage device may be a hard disk, which is not limited here. External storage devices are used to store data permanently.

图3示出根据本发明一实施例的面向对象的缓存写入方法步骤S103的具体实现流程图的示意图。如图3所示,通过通用对象存储接口按照预设协议规定的参数类型和参数格式将待写入对象序列化为流,包括:FIG. 3 shows a schematic diagram of a specific implementation flowchart of step S103 of the object-oriented cache writing method according to an embodiment of the present invention. As shown in Figure 3, the object to be written is serialized into a stream through the general object storage interface according to the parameter type and parameter format stipulated in the preset protocol, including:

在步骤S301中,通过通用对象存储接口确定预设协议规定的所有参数类型,并确定待写入对象对应的所有参数类型的参数值;In step S301, determine all parameter types specified in the preset protocol through the common object storage interface, and determine parameter values of all parameter types corresponding to the object to be written;

在步骤S302中,通过通用对象存储接口按照预设协议规定的参数格式,将预设协议的信息以及待写入对象对应的所有参数类型的参数值转换为流。In step S302, the information of the preset protocol and parameter values of all parameter types corresponding to the object to be written are converted into a stream through the common object storage interface according to the parameter format specified by the preset protocol.

其中,预设协议的信息可以包括预设协议的标识和预设协议的版本号。参数格式可以包括流中各个参数的顺序。参数格式还可以包括参数的编码标准,例如,参数的编码标准为ASCII(American Standard Code for Information Interchange,美国标准信息交换代码)。Wherein, the information of the preset protocol may include the identifier of the preset protocol and the version number of the preset protocol. The parameter format can include the order of the individual parameters in the stream. The parameter format may also include a coding standard of the parameter, for example, the coding standard of the parameter is ASCII (American Standard Code for Information Interchange, American Standard Code for Information Interchange).

在一种可能的实现方式中,参数类型包括:对象所属的类的名称参数、对象的全部属性名称参数、对象的全部属性值参数、对象的全部方法的名称参数、对象所属的类创建对象的方法的名称参数、对象所属的类的全部属性名称参数和对象所属的类的全部属性值参数等。In a possible implementation, the parameter types include: name parameters of the class to which the object belongs, name parameters of all attributes of the object, parameters of all attribute values of the object, name parameters of all methods of the object, and parameters of the class to which the object belongs The name parameter of the method, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs, etc.

例如,待写入对象的参数包括:待写入对象所属的类的名称、待写入对象的全部属性名称、待写入对象的全部属性值、待写入对象的全部方法的名称、待写入对象所述的类创建该待写入对象的方法的名称、待写入对象所属的类的全部属性名称和待写入对象所属的类的全部属性值。For example, the parameters of the object to be written include: the name of the class to which the object to be written belongs, all attribute names of the object to be written, all attribute values of the object to be written, names of all methods of the object to be written, The name of the method for creating the object to be written by the class described in the input object, all attribute names of the class to which the object to be written belongs, and all attribute values of the class to which the object to be written belongs.

这样,通过封装通用对象存储接口,设置能够用于任意类的序列化的预设协议,根据本发明实施例的面向对象的缓存写入方法能够将面向对象语言与缓存相结合,能够通过封装的通用对象存储接口实现直接写入面向对象语言中的对象,从而大大减少开发工作量,提高开发的便携性和效率,并能降低外部存储设备的读写负载,解决外部存储设备的读写性能瓶颈问题,从而大大提高系统性能;在将本发明实施例的面向对象的缓存写入方法应用于服务器端的情况下,可以大大提高服务器的访问速度,支持更高的并发,从而相同用户量所需要的服务器数量大大减小。In this way, by encapsulating the common object storage interface and setting a preset protocol that can be used for serialization of any class, the object-oriented cache writing method according to the embodiment of the present invention can combine the object-oriented language with the cache, and can pass the encapsulation The universal object storage interface enables direct writing of objects in object-oriented languages, thereby greatly reducing the development workload, improving the portability and efficiency of development, reducing the read and write load of external storage devices, and solving the read and write performance bottleneck of external storage devices problems, thereby greatly improving system performance; when the object-oriented cache writing method of the embodiment of the present invention is applied to the server side, the access speed of the server can be greatly improved, and higher concurrency can be supported, so that the same amount of users needs The number of servers is greatly reduced.

实施例2Example 2

图4示出根据本发明一实施例的面向对象的缓存读取方法的实现流程图。如图4所示,该方法主要包括:FIG. 4 shows a flowchart of an implementation of an object-oriented cache reading method according to an embodiment of the present invention. As shown in Figure 4, the method mainly includes:

在步骤S401中,在接收到查询请求的情况下,通过通用对象查询接口确定查询请求对应的键。In step S401, when a query request is received, the key corresponding to the query request is determined through the general object query interface.

其中,通用对象查询接口可以是根据查询请求查询类的对象的通用接口,供外部调用。调用该通用对象查询接口可以直接根据查询请求从面向对象的缓存中查询及获取对象,即该通用对象查询接口返回的结果是对象。该通用对象查询接口支持对任意类的查询。Wherein, the general object query interface may be a general interface for querying objects of a class according to a query request for external calls. Calling the general object query interface can directly query and obtain objects from the object-oriented cache according to the query request, that is, the result returned by the general object query interface is an object. This generic object query interface supports queries on arbitrary classes.

在本发明实施例中,通过通用对象查询接口确定查询请求对应的键可以为:通过通用对象查询接口确定查询请求对应的查询条件,根据预先存储的映射列表确定查询条件对应的键。In the embodiment of the present invention, determining the key corresponding to the query request through the general object query interface may be: determining the query condition corresponding to the query request through the general object query interface, and determining the key corresponding to the query condition according to a pre-stored mapping list.

在步骤S402中,若通过通用对象查询接口从缓存中查找到键对应的流,则按照预设协议规定的参数类型和参数格式将流反序列化为对象,预设协议能够用于任意类的反序列化。In step S402, if the stream corresponding to the key is found from the cache through the general object query interface, the stream is deserialized into an object according to the parameter type and parameter format specified in the preset protocol. The preset protocol can be used for any type of Deserialize.

在通过通用对象查询接口确定查询请求对应的键之后,通过通用对象查询接口根据键基于哈希算法在缓存中进行查找。After the key corresponding to the query request is determined through the general object query interface, the key is searched in the cache based on the hash algorithm through the general object query interface.

在本发明实施例中,可以预先设计能够用于任意类的反序列化的通用的预设协议,通过通用对象查询接口可以调用该预设协议,以实现在缓存中查询对象。由于无需为每个类分别设计协议,从而大大减少了开发工作量,提高了开发便捷性及开发效率。In the embodiment of the present invention, a general preset protocol that can be used for deserialization of any class can be pre-designed, and the preset protocol can be called through a general object query interface to realize querying objects in the cache. Since there is no need to design protocols for each class separately, the development workload is greatly reduced, and the convenience and efficiency of development are improved.

在步骤S403中,通过通用对象查询接口返回对象,以响应查询请求。In step S403, the object is returned through the common object query interface to respond to the query request.

在本发明实施例中,当通过通用对象查询接口将流反序列化为对象后,通用对象查询接口将对象提供给外部接口。In the embodiment of the present invention, after the stream is deserialized into an object through the general object query interface, the general object query interface provides the object to the external interface.

本发明实施例通过将从缓存中获取流并反序列化为对象的过程封装为通用对象查询接口,调用该通用对象查询接口,可以直接从缓存中读取面向对象语言中的类的对象。In the embodiment of the present invention, by encapsulating the process of obtaining streams from the cache and deserializing them into objects as a general object query interface, calling the general object query interface can directly read objects of classes in object-oriented languages from the cache.

图5示出根据本发明一实施例的面向对象的缓存读取方法的另一实现流程图的示意图。如图5所示,该方法主要包括:FIG. 5 shows a schematic diagram of another implementation flowchart of an object-oriented cache reading method according to an embodiment of the present invention. As shown in Figure 5, the method mainly includes:

在步骤S501中,在接收到查询请求的情况下,通过通用对象查询接口确定查询请求对应的键。In step S501, when a query request is received, the key corresponding to the query request is determined through the general object query interface.

在步骤S502中,若通过通用对象查询接口从缓存中查找到键对应的流,则按照预设协议规定的参数类型和参数格式将流反序列化为对象,预设协议能够用于任意类的反序列化。In step S502, if the stream corresponding to the key is found from the cache through the general object query interface, the stream is deserialized into an object according to the parameter type and parameter format specified in the preset protocol. The preset protocol can be used for any type of Deserialize.

在步骤S503中,通过通用对象查询接口返回对象,以响应查询请求。In step S503, the object is returned through the common object query interface to respond to the query request.

在步骤S504中,若通过通用对象查询接口从缓存中查找不到键对应的流,则从外部存储设备中查找键对应的流。In step S504, if the stream corresponding to the key cannot be found from the cache through the general object query interface, the stream corresponding to the key is searched from an external storage device.

在步骤S505中,若从外部存储设备中查找到键对应的流,则按照预设协议规定的参数类型和参数格式将流反序列化为对象,并返回对象,以响应查询请求。In step S505, if the stream corresponding to the key is found from the external storage device, the stream is deserialized into an object according to the parameter type and format specified in the preset protocol, and the object is returned to respond to the query request.

图6示出根据本发明一实施例的面向对象的缓存读取方法步骤S402中按照预设协议规定的参数类型和参数格式将流反序列化为对象的具体实现流程图的示意图。如图6所示,按照预设协议规定的参数类型和参数格式将流反序列化为对象,包括:Fig. 6 shows a schematic diagram of a specific implementation flowchart of deserializing a stream into an object according to the parameter type and parameter format specified in the preset protocol in step S402 of the object-oriented cache reading method according to an embodiment of the present invention. As shown in Figure 6, deserialize the stream into an object according to the parameter type and parameter format stipulated in the preset protocol, including:

在步骤S601中,从流中获取预设协议的信息,并根据预设协议的信息确定预设协议规定的参数类型和参数格式;In step S601, the information of the preset protocol is obtained from the stream, and the parameter type and parameter format specified by the preset protocol are determined according to the information of the preset protocol;

在步骤S602中,根据预设协议规定的参数类型和参数格式,以及流中所有参数类型的参数值,将流反序列化为对象。In step S602, the stream is deserialized into an object according to the parameter type and parameter format stipulated in the preset protocol, and parameter values of all parameter types in the stream.

其中,预设协议的信息可以包括预设协议的标识和预设协议的版本号。根据预设协议的标识和预设协议的版本号,可以确定预设协议规定的参数类型和参数格式,从而可以确定流中的所有参数类型和参数格式。Wherein, the information of the preset protocol may include the identifier of the preset protocol and the version number of the preset protocol. According to the identifier of the preset protocol and the version number of the preset protocol, the parameter type and parameter format specified in the preset protocol can be determined, so that all parameter types and parameter formats in the stream can be determined.

在一种可能的实现方式中,参数类型包括:对象所属的类的名称参数、对象的全部属性名称参数、对象的全部属性值参数、对象的全部方法的名称参数、对象所属的类创建对象的方法的名称参数、对象所属的类的全部属性名称参数和对象所属的类的全部属性值参数等。In a possible implementation, the parameter types include: name parameters of the class to which the object belongs, name parameters of all attributes of the object, parameters of all attribute values of the object, name parameters of all methods of the object, and parameters of the class to which the object belongs The name parameter of the method, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs, etc.

这样,通过封装通用对象查询接口,设置能够用于任意类的反序列化的预设协议,根据本发明实施例的面向对象的缓存读取方法能够将面向对象语言与缓存相结合,能够通过通用对象查询接口实现直接读取面向对象语言中的对象,从而大大减少开发工作量,提高开发的便携性和效率,并能降低外部存储设备的读写负载,解决外部存储设备的读写性能瓶颈问题,从而大大提高系统性能;在将本发明实施例的面向对象的缓存读取方法应用于服务器端的情况下,可以大大提高服务器的访问速度,支持更高的并发,从而相同用户量所需要的服务器数量大大减小。In this way, by encapsulating the general object query interface and setting a preset protocol that can be used for deserialization of any class, the object-oriented cache reading method according to the embodiment of the present invention can combine the object-oriented language with the cache, and can pass the general The object query interface can directly read the objects in the object-oriented language, thereby greatly reducing the development workload, improving the portability and efficiency of development, reducing the read and write load of external storage devices, and solving the bottleneck problem of the read and write performance of external storage devices , thereby greatly improving system performance; when the object-oriented cache reading method of the embodiment of the present invention is applied to the server side, the access speed of the server can be greatly improved, and higher concurrency can be supported, so that the server required by the same amount of users The number is greatly reduced.

实施例3Example 3

图7示出根据本发明一实施例的面向对象的缓存写入装置的结构框图。该装置可以为服务器,也可以为其他缓存写入装置,在此不作限定。为了便于说明,仅示出了与本发明实施例相关的部分。如图7所示,该装置包括:Fig. 7 shows a structural block diagram of an object-oriented cache writing device according to an embodiment of the present invention. The device may be a server, or other cache writing device, which is not limited here. For ease of description, only parts related to the embodiments of the present invention are shown. As shown in Figure 7, the device includes:

通用对象存储接口调用模块71,用于在接收到写入请求的情况下,调用通用对象存储接口;A general object storage interface calling module 71, configured to call the general object storage interface when a write request is received;

键生成模块72,用于通过通用对象存储接口确定写入请求对应的待写入对象的唯一标识符,并根据唯一标识符生成待写入对象的键;The key generation module 72 is used to determine the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and generate the key of the object to be written according to the unique identifier;

序列化模块73,用于通过通用对象存储接口按照预设协议规定的参数类型和参数格式将待写入对象序列化为流,预设协议能够用于任意类的序列化;The serialization module 73 is used to serialize the object to be written into a stream according to the parameter type and parameter format specified in the preset protocol through the general object storage interface, and the preset protocol can be used for serialization of any class;

缓存写入模块74,用于通过通用对象存储接口根据键将流写入缓存。The cache writing module 74 is configured to write the stream into the cache according to the key through the common object storage interface.

在一种可能的实现方式中,装置还包括:In a possible implementation manner, the device further includes:

外部存储设备写入模块75,用于根据键将流写入外部存储设备。The external storage device writing module 75 is configured to write the stream into the external storage device according to the key.

在一种可能的实现方式中,序列化模块73包括:In a possible implementation, the serialization module 73 includes:

参数值确定子模块731,用于通过通用对象存储接口确定预设协议规定的所有参数类型,并确定待写入对象对应的所有参数类型的参数值;The parameter value determination sub-module 731 is used to determine all parameter types specified in the preset protocol through the common object storage interface, and determine the parameter values of all parameter types corresponding to the object to be written;

序列化子模块732,用于通过通用对象存储接口按照预设协议规定的参数格式,将预设协议的信息以及待写入对象对应的所有参数类型的参数值转换为流。The serialization sub-module 732 is configured to convert the information of the preset protocol and the parameter values of all parameter types corresponding to the object to be written into a stream through the common object storage interface according to the parameter format specified by the preset protocol.

在一种可能的实现方式中,参数类型包括:对象所属的类的名称参数、对象的全部属性名称参数、对象的全部属性值参数、对象的全部方法的名称参数、对象所属的类创建对象的方法的名称参数、对象所属的类的全部属性名称参数和对象所属的类的全部属性值参数等。In a possible implementation, the parameter types include: name parameters of the class to which the object belongs, name parameters of all attributes of the object, parameters of all attribute values of the object, name parameters of all methods of the object, and parameters of the class to which the object belongs The name parameter of the method, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs, etc.

这样,通过封装通用对象存储接口,设置能够用于任意类的序列化的预设协议,根据本发明实施例的面向对象的缓存写入装置能够将面向对象语言与缓存相结合,能够通过封装的通用对象存储接口实现直接写入面向对象语言中的对象,从而大大减少开发工作量,提高开发的便携性和效率,并能降低外部存储设备的读写负载,解决外部存储设备的读写性能瓶颈问题,从而大大提高系统性能;在将本发明实施例的面向对象的缓存写入装置应用于服务器端的情况下,可以大大提高服务器的访问速度,支持更高的并发,从而相同用户量所需要的服务器数量大大减小。In this way, by encapsulating the general object storage interface and setting a preset protocol that can be used for serialization of any class, the object-oriented cache writing device according to the embodiment of the present invention can combine the object-oriented language with the cache, and can pass the encapsulated The universal object storage interface enables direct writing of objects in object-oriented languages, thereby greatly reducing the development workload, improving the portability and efficiency of development, reducing the read and write load of external storage devices, and solving the read and write performance bottleneck of external storage devices problems, thereby greatly improving system performance; when the object-oriented cache writing device of the embodiment of the present invention is applied to the server side, the access speed of the server can be greatly improved, and higher concurrency can be supported, so that the same amount of users needs The number of servers is greatly reduced.

实施例4Example 4

图8示出根据本发明一实施例的面向对象的缓存读取装置的结构框图。该装置可以为服务器,也可以为其他缓存读取装置,在此不作限定。为了便于说明,仅示出了与本发明实施例相关的部分。如图8所示,该装置包括:Fig. 8 shows a structural block diagram of an object-oriented cache reading device according to an embodiment of the present invention. The device may be a server, or other cache reading device, which is not limited here. For ease of description, only parts related to the embodiments of the present invention are shown. As shown in Figure 8, the device includes:

键确定模块81,用于在接收到查询请求的情况下,通过通用对象查询接口确定查询请求对应的键;A key determination module 81, configured to determine the key corresponding to the query request through the general object query interface when the query request is received;

反序列化模块82,用于若通过通用对象查询接口从缓存中查找到键对应的流,则按照预设协议规定的参数类型和参数格式将流反序列化为对象,预设协议能够用于任意类的反序列化;The deserialization module 82 is used to deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol if the stream corresponding to the key is found from the cache through the general object query interface. The preset protocol can be used for Deserialization of arbitrary classes;

第一查询响应模块83,用于通过通用对象查询接口返回对象,以响应查询请求。The first query response module 83 is configured to return objects through the common object query interface to respond to query requests.

在一种可能的实现方式中,装置还包括:In a possible implementation manner, the device further includes:

第一查找模块84,用于若通过通用对象查询接口从缓存中查找不到键对应的流,则从外部存储设备中查找键对应的流;The first search module 84 is used to find the stream corresponding to the key from the external storage device if the stream corresponding to the key cannot be found from the cache through the general object query interface;

第二查询响应模块85,用于若从外部存储设备中查找到键对应的流,则按照预设协议规定的参数类型和参数格式将流反序列化为对象,并返回对象,以响应查询请求。The second query response module 85 is configured to deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol if the stream corresponding to the key is found from the external storage device, and return the object to respond to the query request .

在一种可能的实现方式中,反序列化模块82包括:In a possible implementation, the deserialization module 82 includes:

参数类型和格式确定子模块821,用于从流中获取预设协议的信息,并根据预设协议的信息确定预设协议规定的参数类型和参数格式;The parameter type and format determination submodule 821 is used to obtain the information of the preset protocol from the stream, and determine the parameter type and parameter format specified in the preset protocol according to the information of the preset protocol;

反序列化子模块822,用于根据预设协议规定的参数类型和参数格式,以及流中所有参数类型的参数值,将流反序列化为对象。The deserialization submodule 822 is configured to deserialize the stream into an object according to the parameter type and parameter format stipulated in the preset protocol, and the parameter values of all parameter types in the stream.

在一种可能的实现方式中,参数类型包括:对象所属的类的名称参数、对象的全部属性名称参数、对象的全部属性值参数、对象的全部方法的名称参数、对象所属的类创建对象的方法的名称参数、对象所属的类的全部属性名称参数和对象所属的类的全部属性值参数等。In a possible implementation, the parameter types include: name parameters of the class to which the object belongs, name parameters of all attributes of the object, parameters of all attribute values of the object, name parameters of all methods of the object, and parameters of the class to which the object belongs The name parameter of the method, all the attribute name parameters of the class to which the object belongs, and all the attribute value parameters of the class to which the object belongs, etc.

这样,通过封装通用对象查询接口,设置能够用于任意类的反序列化的预设协议,根据本发明实施例的面向对象的缓存读取装置能够将面向对象语言与缓存相结合,能够通过通用对象查询接口实现直接读取面向对象语言中的对象,从而大大减少开发工作量,提高开发的便携性和效率,并能降低外部存储设备的读写负载,解决外部存储设备的读写性能瓶颈问题,从而大大提高系统性能;在将本发明实施例的面向对象的缓存读取装置应用于服务器端的情况下,可以大大提高服务器的访问速度,支持更高的并发,从而相同用户量所需要的服务器数量大大减小。In this way, by encapsulating the general object query interface and setting a preset protocol that can be used for deserialization of any class, the object-oriented cache reading device according to the embodiment of the present invention can combine the object-oriented language with the cache, and can pass the general The object query interface can directly read the objects in the object-oriented language, thereby greatly reducing the development workload, improving the portability and efficiency of development, reducing the read and write load of external storage devices, and solving the bottleneck problem of the read and write performance of external storage devices , thereby greatly improving system performance; when the object-oriented cache reading device of the embodiment of the present invention is applied to the server side, the access speed of the server can be greatly improved, and higher concurrency can be supported, so that the server required by the same amount of users The number is greatly reduced.

实施例5Example 5

图9示出了本发明的另一个实施例的一种面向对象的缓存写入装置的一示例性的结构框图。所述面向对象的缓存写入装置1100可以是具备计算能力的主机服务器、个人计算机PC、或者可携带的便携式计算机或终端等。本发明具体实施例并不对计算节点的具体实现做限定。FIG. 9 shows an exemplary structural block diagram of an object-oriented cache writing device according to another embodiment of the present invention. The object-oriented cache writing apparatus 1100 may be a host server with computing capabilities, a personal computer PC, or a portable portable computer or terminal. The specific embodiments of the present invention do not limit the specific implementation of the computing nodes.

所述面向对象的缓存写入装置1100包括处理器(processor)1110、通信接口(Communications Interface)1120、存储器(memory)1130和总线1140。其中,处理器1110、通信接口1120、以及存储器1130通过总线1140完成相互间的通信。The object-oriented cache writing device 1100 includes a processor (processor) 1110 , a communication interface (Communications Interface) 1120 , a memory (memory) 1130 and a bus 1140 . Wherein, the processor 1110 , the communication interface 1120 , and the memory 1130 communicate with each other through the bus 1140 .

通信接口1120用于与网络设备通信,其中网络设备包括例如虚拟机管理中心、共享存储等。The communication interface 1120 is used for communicating with network devices, where the network devices include, for example, a virtual machine management center, shared storage, and the like.

处理器1110用于执行程序。处理器1110可能是一个中央处理器CPU,或者是专用集成电路ASIC(Application Specific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路。The processor 1110 is used to execute programs. The processor 1110 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.

存储器1130用于存放文件。存储器1130可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。存储器1130也可以是存储器阵列。存储器1130还可能被分块,并且所述块可按一定的规则组合成虚拟卷。The storage 1130 is used for storing files. The memory 1130 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory. Memory 1130 may also be a memory array. The storage 1130 may also be divided into blocks, and the blocks may be combined into virtual volumes according to certain rules.

在一种可能的实施方式中,上述程序可为包括计算机操作指令的程序代码。该程序具体可包含用于执行以下操作的指令:In a possible implementation manner, the above program may be a program code including computer operation instructions. Specifically, the program may contain instructions to:

在接收到写入请求的情况下,调用通用对象存储接口;In the case of receiving a write request, call the general object storage interface;

通过所述通用对象存储接口确定所述写入请求对应的待写入对象的唯一标识符,并根据所述唯一标识符生成所述待写入对象的键;Determine the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and generate a key of the object to be written according to the unique identifier;

通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,所述预设协议能够用于任意类的序列化;Serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class;

通过所述通用对象存储接口根据所述键将所述流写入缓存。Writing the stream into the cache according to the key through the common object storage interface.

假设上述为第一种可能的实施方式,则在第一种可能的实施方式作为基础而提供的第二种可能的实施方式中,该程序还可包含用于执行以下操作的指令:Assuming that the above is the first possible implementation manner, in the second possible implementation manner provided on the basis of the first possible implementation manner, the program may further include instructions for performing the following operations:

在通过所述通用对象存储接口根据所述键将所述流写入缓存之后,根据所述键将所述流写入外部存储设备。After writing the stream into the cache according to the key through the common object storage interface, write the stream into an external storage device according to the key.

在第一种可能的实施方式作为基础而提供的第三种可能的实施方式中,该程序还可包含用于执行以下操作的指令:In a third possible implementation manner provided on the basis of the first possible implementation manner, the program may further include instructions for performing the following operations:

通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,包括:Serialize the object to be written into a stream according to the parameter type and parameter format specified in the preset protocol through the general object storage interface, including:

通过所述通用对象存储接口确定所述预设协议规定的所有所述参数类型,并确定所述待写入对象对应的所有所述参数类型的参数值;determining all the parameter types specified in the preset protocol through the general object storage interface, and determining parameter values of all the parameter types corresponding to the object to be written;

通过所述通用对象存储接口按照所述预设协议规定的所述参数格式,将所述预设协议的信息以及所述待写入对象对应的所有所述参数类型的参数值转换为流。Converting information of the preset protocol and parameter values of all parameter types corresponding to the object to be written into a stream through the general object storage interface according to the parameter format specified in the preset protocol.

在第一种、第二种或第三种可能的实施方式作为基础而提供的第四种可能的实施方式中,该程序还可包含用于执行以下操作的指令:In the fourth possible implementation manner provided based on the first, second or third possible implementation manner, the program may further include instructions for performing the following operations:

所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。The parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, name parameters of all methods of the object, and the creation parameters of the class to which the object belongs Name parameters of the method of the object, all attribute name parameters of the class to which the object belongs, and all attribute value parameters of the class to which the object belongs.

实施例6Example 6

图10示出了本发明的另一个实施例的一种面向对象的缓存读取装置的一示例性的结构框图。所述面向对象的缓存读取装置1200可以是具备计算能力的主机服务器、个人计算机PC、或者可携带的便携式计算机或终端等。本发明具体实施例并不对计算节点的具体实现做限定。FIG. 10 shows an exemplary structural block diagram of an object-oriented cache reading device according to another embodiment of the present invention. The object-oriented cache reading device 1200 may be a host server with computing capabilities, a personal computer PC, or a portable portable computer or terminal. The specific embodiments of the present invention do not limit the specific implementation of the computing nodes.

所述面向对象的缓存读取装置1200包括处理器1210、通信接口1220、存储器1230和总线1240。其中,处理器1210、通信接口1220、以及存储器1230通过总线1240完成相互间的通信。The object-oriented cache reading device 1200 includes a processor 1210 , a communication interface 1220 , a memory 1230 and a bus 1240 . Wherein, the processor 1210 , the communication interface 1220 , and the memory 1230 communicate with each other through the bus 1240 .

通信接口1220用于与网络设备通信,其中网络设备包括例如虚拟机管理中心、共享存储等。The communication interface 1220 is used for communicating with network devices, where the network devices include, for example, a virtual machine management center, shared storage, and the like.

处理器1210用于执行程序。处理器1210可能是一个中央处理器CPU,或者是专用集成电路ASIC,或者是被配置成实施本发明实施例的一个或多个集成电路。The processor 1210 is used to execute programs. Processor 1210 may be a central processing unit CPU, or an application specific integrated circuit ASIC, or one or more integrated circuits configured to implement embodiments of the present invention.

存储器1230用于存放文件。存储器1230可能包含高速RAM存储器,也可能还包括非易失性存储器,例如至少一个磁盘存储器。存储器1230也可以是存储器阵列。存储器1230还可能被分块,并且所述块可按一定的规则组合成虚拟卷。The storage 1230 is used to store files. The memory 1230 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory. Memory 1230 may also be a memory array. The storage 1230 may also be divided into blocks, and the blocks may be combined into virtual volumes according to certain rules.

在一种可能的实施方式中,上述程序可为包括计算机操作指令的程序代码。该程序具体可包含用于执行以下操作的指令:In a possible implementation manner, the above program may be a program code including computer operation instructions. Specifically, the program may contain instructions to:

在接收到查询请求的情况下,通过通用对象查询接口确定所述查询请求对应的键;In the case of receiving a query request, determine the key corresponding to the query request through the general object query interface;

若通过所述通用对象查询接口从所述缓存中查找到所述键对应的流,则按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,所述预设协议能够用于任意类的反序列化;If the stream corresponding to the key is found from the cache through the general object query interface, deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can for deserialization of arbitrary classes;

通过所述通用对象查询接口返回所述对象,以响应所述查询请求。Returning the object through the general object query interface to respond to the query request.

假设上述为第一种可能的实施方式,则在第一种可能的实施方式作为基础而提供的第二种可能的实施方式中,该程序还可包含用于执行以下操作的指令:Assuming that the above is the first possible implementation manner, in the second possible implementation manner provided on the basis of the first possible implementation manner, the program may further include instructions for performing the following operations:

在通过通用对象查询接口确定所述查询请求对应的键之后,若通过所述通用对象查询接口从所述缓存中查找不到所述键对应的流,则从外部存储设备中查找所述键对应的流;After the key corresponding to the query request is determined through the general object query interface, if the stream corresponding to the key cannot be found from the cache through the general object query interface, then the key corresponding to the key is searched from the external storage device. flow;

若从所述外部存储设备中查找到所述键对应的流,则按照所述预设协议规定的所述参数类型和所述参数格式将所述流反序列化为所述对象,并返回所述对象,以响应所述查询请求。If the stream corresponding to the key is found from the external storage device, deserialize the stream into the object according to the parameter type and the parameter format stipulated in the preset protocol, and return the said object in response to said query request.

在第一种或第二种可能的实施方式作为基础而提供的第四种可能的实施方式中,该程序还可包含用于执行以下操作的指令:In the fourth possible implementation manner provided based on the first or second possible implementation manner, the program may further include instructions for performing the following operations:

按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,包括:Deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol, including:

从所述流中获取所述预设协议的信息,并根据所述预设协议的信息确定所述预设协议规定的所述参数类型和所述参数格式;Obtaining the information of the preset protocol from the stream, and determining the parameter type and the parameter format specified in the preset protocol according to the information of the preset protocol;

根据所述预设协议规定的所述参数类型和所述参数格式,以及所述流中所有所述参数类型的参数值,将所述流反序列化为所述对象。Deserialize the stream into the object according to the parameter type and the parameter format specified in the preset protocol, and all parameter values of the parameter type in the stream.

在第一种或第二种可能的实施方式作为基础而提供的第四种可能的实施方式中,该程序还可包含用于执行以下操作的指令:In the fourth possible implementation manner provided based on the first or second possible implementation manner, the program may further include instructions for performing the following operations:

所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。The parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, name parameters of all methods of the object, and the creation parameters of the class to which the object belongs Name parameters of the method of the object, all attribute name parameters of the class to which the object belongs, and all attribute value parameters of the class to which the object belongs.

本领域普通技术人员可以意识到,本文所描述的实施例中的各示例性模块及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件形式来实现,取决于技术方案的特定应用和设计约束条件。专业技术人员可以针对特定的应用选择不同的方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those skilled in the art can appreciate that each exemplary module and algorithm steps in the embodiments described herein can be realized by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in the form of hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may choose different methods to implement the described functions for specific applications, but this implementation should not be regarded as exceeding the scope of the present invention.

如果以计算机软件的形式来实现所述功能并作为独立的产品销售或使用时,则在一定程度上可认为本发明的技术方案的全部或部分(例如对现有技术做出贡献的部分)是以计算机软件产品的形式体现的。该计算机软件产品通常存储在计算机可读取的非易失性存储介质中,包括若干指令用以使得计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各实施例方法的全部或部分步骤。而前述的存储介质包括U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of computer software and sold or used as an independent product, it can be considered that all or part of the technical solution of the present invention (such as the part that contributes to the prior art) is In the form of computer software products. The computer software product is usually stored in a computer-readable non-volatile storage medium, and includes several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all the methods of the various embodiments of the present invention. or partial steps. The aforementioned storage medium includes various media capable of storing program codes such as U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk.

以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Anyone skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention. Should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the protection scope of the claims.

Claims (16)

1.一种面向对象的缓存写入方法,其特征在于,包括:1. An object-oriented cache write method, characterized in that, comprising: 在接收到写入请求的情况下,调用通用对象存储接口;In the case of receiving a write request, call the general object storage interface; 通过所述通用对象存储接口确定所述写入请求对应的待写入对象的唯一标识符,并根据所述唯一标识符生成所述待写入对象的键;Determine the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and generate a key of the object to be written according to the unique identifier; 通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,所述预设协议能够用于任意类的序列化;Serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class; 通过所述通用对象存储接口根据所述键将所述流写入缓存。Writing the stream into the cache according to the key through the common object storage interface. 2.根据权利要求1所述的方法,其特征在于,在通过所述通用对象存储接口根据所述键将所述流写入缓存之后,所述方法还包括:2. The method according to claim 1, wherein after writing the stream into the cache according to the key through the general object storage interface, the method further comprises: 根据所述键将所述流写入外部存储设备。Write the stream to external storage according to the key. 3.根据权利要求1所述的方法,其特征在于,通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,包括:3. The method according to claim 1, wherein serializing the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol includes: 通过所述通用对象存储接口确定所述预设协议规定的所有所述参数类型,并确定所述待写入对象对应的所有所述参数类型的参数值;determining all the parameter types specified in the preset protocol through the general object storage interface, and determining parameter values of all the parameter types corresponding to the object to be written; 通过所述通用对象存储接口按照所述预设协议规定的所述参数格式,将所述预设协议的信息以及所述待写入对象对应的所有所述参数类型的参数值转换为流。Converting information of the preset protocol and parameter values of all parameter types corresponding to the object to be written into a stream through the general object storage interface according to the parameter format specified in the preset protocol. 4.根据权利要求1至3任意一项所述的方法,其特征在于,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。4. The method according to any one of claims 1 to 3, wherein the parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, and all attribute values of the object Parameters, name parameters of all methods of the object, name parameters of the class to which the object belongs parameter. 5.一种面向对象的缓存读取方法,其特征在于,包括:5. An object-oriented cache reading method, comprising: 在接收到查询请求的情况下,通过通用对象查询接口确定所述查询请求对应的键;In the case of receiving a query request, determine the key corresponding to the query request through the general object query interface; 若通过所述通用对象查询接口从所述缓存中查找到所述键对应的流,则按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,所述预设协议能够用于任意类的反序列化;If the stream corresponding to the key is found from the cache through the general object query interface, deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can for deserialization of arbitrary classes; 通过所述通用对象查询接口返回所述对象,以响应所述查询请求。Returning the object through the general object query interface to respond to the query request. 6.根据权利要求5所述的方法,其特征在于,在通过通用对象查询接口确定所述查询请求对应的键之后,所述方法还包括:6. The method according to claim 5, characterized in that, after the key corresponding to the query request is determined through the general object query interface, the method further comprises: 若通过所述通用对象查询接口从所述缓存中查找不到所述键对应的流,则从外部存储设备中查找所述键对应的流;If the stream corresponding to the key cannot be found from the cache through the general object query interface, then search for the stream corresponding to the key from an external storage device; 若从所述外部存储设备中查找到所述键对应的流,则按照所述预设协议规定的所述参数类型和所述参数格式将所述流反序列化为所述对象,并返回所述对象,以响应所述查询请求。If the stream corresponding to the key is found from the external storage device, deserialize the stream into the object according to the parameter type and the parameter format stipulated in the preset protocol, and return the said object in response to said query request. 7.根据权利要求5或6所述的方法,其特征在于,按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,包括:7. The method according to claim 5 or 6, wherein deserializing the stream into an object according to the parameter type and parameter format stipulated in the preset protocol includes: 从所述流中获取所述预设协议的信息,并根据所述预设协议的信息确定所述预设协议规定的所述参数类型和所述参数格式;Obtaining the information of the preset protocol from the stream, and determining the parameter type and the parameter format specified in the preset protocol according to the information of the preset protocol; 根据所述预设协议规定的所述参数类型和所述参数格式,以及所述流中所有所述参数类型的参数值,将所述流反序列化为所述对象。Deserialize the stream into the object according to the parameter type and the parameter format specified in the preset protocol, and all parameter values of the parameter type in the stream. 8.根据权利要求5或6所述的方法,其特征在于,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。8. The method according to claim 5 or 6, wherein the parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, the Name parameters of all methods of the object, name parameters of methods for creating the object of the class to which the object belongs, name parameters of all attributes of the class to which the object belongs, and all attribute value parameters of the class to which the object belongs. 9.一种面向对象的缓存写入装置,其特征在于,包括:9. An object-oriented cache writing device, characterized in that, comprising: 通用对象存储接口调用模块,用于在接收到写入请求的情况下,调用通用对象存储接口;A generic object storage interface calling module, configured to call the generic object storage interface when a write request is received; 键生成模块,用于通过所述通用对象存储接口确定所述写入请求对应的待写入对象的唯一标识符,并根据所述唯一标识符生成所述待写入对象的键;A key generation module, configured to determine the unique identifier of the object to be written corresponding to the write request through the general object storage interface, and generate the key of the object to be written according to the unique identifier; 序列化模块,用于通过所述通用对象存储接口按照预设协议规定的参数类型和参数格式将所述待写入对象序列化为流,所述预设协议能够用于任意类的序列化;A serialization module, configured to serialize the object to be written into a stream through the general object storage interface according to the parameter type and parameter format specified in the preset protocol, and the preset protocol can be used for serialization of any class; 缓存写入模块,用于通过所述通用对象存储接口根据所述键将所述流写入缓存。A cache writing module, configured to write the stream into the cache according to the key through the common object storage interface. 10.根据权利要求9所述的装置,其特征在于,所述装置还包括:10. The device according to claim 9, further comprising: 外部存储设备写入模块,用于根据所述键将所述流写入外部存储设备。An external storage device writing module, configured to write the stream into an external storage device according to the key. 11.根据权利要求9所述的装置,其特征在于,所述序列化模块包括:11. The device according to claim 9, wherein the serialization module comprises: 参数值确定子模块,用于通过所述通用对象存储接口确定所述预设协议规定的所有所述参数类型,并确定所述待写入对象对应的所有所述参数类型的参数值;A parameter value determining submodule, configured to determine all the parameter types specified in the preset protocol through the general object storage interface, and determine parameter values of all the parameter types corresponding to the object to be written; 序列化子模块,用于通过所述通用对象存储接口按照所述预设协议规定的所述参数格式,将所述预设协议的信息以及所述待写入对象对应的所有所述参数类型的参数值转换为流。The serialization submodule is used to store the information of the preset protocol and all the parameter types corresponding to the object to be written according to the parameter format stipulated in the preset protocol through the general object storage interface The parameter value is converted to a stream. 12.根据权利要求9至11任意一项所述的装置,其特征在于,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。12. The device according to any one of claims 9 to 11, wherein the parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, and all attribute values of the object Parameters, name parameters of all methods of the object, name parameters of the class to which the object belongs parameter. 13.一种面向对象的缓存读取装置,其特征在于,包括:13. An object-oriented cache reading device, comprising: 键确定模块,用于在接收到查询请求的情况下,通过通用对象查询接口确定所述查询请求对应的键;A key determination module, configured to determine the key corresponding to the query request through the general object query interface when the query request is received; 反序列化模块,用于若通过所述通用对象查询接口从所述缓存中查找到所述键对应的流,则按照预设协议规定的参数类型和参数格式将所述流反序列化为对象,所述预设协议能够用于任意类的反序列化;A deserialization module, configured to deserialize the stream into an object according to the parameter type and parameter format specified in the preset protocol if the stream corresponding to the key is found from the cache through the general object query interface , the preset protocol can be used for deserialization of any class; 第一查询响应模块,用于通过所述通用对象查询接口返回所述对象,以响应所述查询请求。The first query response module is configured to return the object through the general object query interface to respond to the query request. 14.根据权利要求13所述的装置,其特征在于,所述装置还包括:14. The device according to claim 13, further comprising: 第一查找模块,用于若通过所述通用对象查询接口从所述缓存中查找不到所述键对应的流,则从外部存储设备中查找所述键对应的流;A first search module, configured to search for the stream corresponding to the key from an external storage device if the stream corresponding to the key cannot be found from the cache through the general object query interface; 第二查询响应模块,用于若从所述外部存储设备中查找到所述键对应的流,则按照所述预设协议规定的所述参数类型和所述参数格式将所述流反序列化为所述对象,并返回所述对象,以响应所述查询请求。The second query response module is configured to deserialize the stream according to the parameter type and the parameter format stipulated in the preset protocol if the stream corresponding to the key is found from the external storage device for the object and return the object in response to the query request. 15.根据权利要求13或14所述的装置,其特征在于,所述反序列化模块包括:15. The device according to claim 13 or 14, wherein the deserialization module comprises: 参数类型和格式确定子模块,用于从所述流中获取所述预设协议的信息,并根据所述预设协议的信息确定所述预设协议规定的所述参数类型和所述参数格式;A parameter type and format determining submodule, configured to obtain information of the preset protocol from the stream, and determine the parameter type and the parameter format specified in the preset protocol according to the information of the preset protocol ; 反序列化子模块,用于根据所述预设协议规定的所述参数类型和所述参数格式,以及所述流中所有所述参数类型的参数值,将所述流反序列化为所述对象。The deserialization submodule is used to deserialize the stream into the object. 16.根据权利要求13或14所述的装置,其特征在于,所述参数类型包括:对象所属的类的名称参数、所述对象的全部属性名称参数、所述对象的全部属性值参数、所述对象的全部方法的名称参数、所述对象所属的类创建所述对象的方法的名称参数、所述对象所属的类的全部属性名称参数和所述对象所属的类的全部属性值参数。16. The device according to claim 13 or 14, wherein the parameter types include: the name parameter of the class to which the object belongs, all attribute name parameters of the object, all attribute value parameters of the object, the Name parameters of all methods of the object, name parameters of methods for creating the object of the class to which the object belongs, name parameters of all attributes of the class to which the object belongs, and all attribute value parameters of the class to which the object belongs.
CN201610391139.2A 2016-06-03 2016-06-03 Object-oriented cache writing and reading method and device Expired - Fee Related CN106095698B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610391139.2A CN106095698B (en) 2016-06-03 2016-06-03 Object-oriented cache writing and reading method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610391139.2A CN106095698B (en) 2016-06-03 2016-06-03 Object-oriented cache writing and reading method and device

Publications (2)

Publication Number Publication Date
CN106095698A true CN106095698A (en) 2016-11-09
CN106095698B CN106095698B (en) 2019-04-23

Family

ID=57447079

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610391139.2A Expired - Fee Related CN106095698B (en) 2016-06-03 2016-06-03 Object-oriented cache writing and reading method and device

Country Status (1)

Country Link
CN (1) CN106095698B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108228912A (en) * 2018-02-12 2018-06-29 浙江中控技术股份有限公司 The processing method and relevant apparatus of a kind of business datum
CN108345614A (en) * 2017-01-23 2018-07-31 易族智汇(北京)科技有限公司 A kind of device based on memory storage and display webpage
CN108540313A (en) * 2018-03-21 2018-09-14 烽火通信科技股份有限公司 A method of the northbound interface Acquisition Circuit structure based on type identifier
CN109343836A (en) * 2018-08-31 2019-02-15 阿里巴巴集团控股有限公司 Data Serialization, data antitone sequence method, device and equipment
CN109656889A (en) * 2018-12-26 2019-04-19 百度在线网络技术(北京)有限公司 File system implementation method, device, equipment and storage medium based on block chain
CN110413644A (en) * 2019-06-17 2019-11-05 中国平安人寿保险股份有限公司 A kind of data cache method, electronic device and computer readable storage medium
CN112948336A (en) * 2021-03-30 2021-06-11 联想凌拓科技有限公司 Data acceleration method, cache unit, electronic device and storage medium
WO2022012143A1 (en) * 2020-07-17 2022-01-20 华为技术有限公司 Memory management technology and computer system
CN117113090A (en) * 2023-10-23 2023-11-24 一网互通(北京)科技有限公司 Data source label marking method and device and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120222007A1 (en) * 2007-11-27 2012-08-30 International Business Machines Corporation Automated defect classification
CN102981884A (en) * 2012-11-22 2013-03-20 用友软件股份有限公司 Serializing device and serializing method
CN103019689A (en) * 2012-11-21 2013-04-03 上海富欣智能交通控制有限公司 Universal object serialization realizing method
CN103488581A (en) * 2013-09-04 2014-01-01 用友软件股份有限公司 Data caching system and data caching method
US20140068188A1 (en) * 2011-11-04 2014-03-06 Recursion Software, Inc. System and method for managing an object cache
CN104346142A (en) * 2013-07-26 2015-02-11 上海星野信息科技有限公司 Data unification processing system and method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120222007A1 (en) * 2007-11-27 2012-08-30 International Business Machines Corporation Automated defect classification
US20140068188A1 (en) * 2011-11-04 2014-03-06 Recursion Software, Inc. System and method for managing an object cache
CN103019689A (en) * 2012-11-21 2013-04-03 上海富欣智能交通控制有限公司 Universal object serialization realizing method
CN102981884A (en) * 2012-11-22 2013-03-20 用友软件股份有限公司 Serializing device and serializing method
CN104346142A (en) * 2013-07-26 2015-02-11 上海星野信息科技有限公司 Data unification processing system and method
CN103488581A (en) * 2013-09-04 2014-01-01 用友软件股份有限公司 Data caching system and data caching method

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345614A (en) * 2017-01-23 2018-07-31 易族智汇(北京)科技有限公司 A kind of device based on memory storage and display webpage
CN108228912A (en) * 2018-02-12 2018-06-29 浙江中控技术股份有限公司 The processing method and relevant apparatus of a kind of business datum
CN108540313B (en) * 2018-03-21 2020-12-29 烽火通信科技股份有限公司 Method for acquiring circuit structure of northbound interface based on type identifier
CN108540313A (en) * 2018-03-21 2018-09-14 烽火通信科技股份有限公司 A method of the northbound interface Acquisition Circuit structure based on type identifier
CN109343836A (en) * 2018-08-31 2019-02-15 阿里巴巴集团控股有限公司 Data Serialization, data antitone sequence method, device and equipment
CN109343836B (en) * 2018-08-31 2021-09-10 创新先进技术有限公司 Data serialization and data deserialization method, device and equipment
CN109656889A (en) * 2018-12-26 2019-04-19 百度在线网络技术(北京)有限公司 File system implementation method, device, equipment and storage medium based on block chain
CN109656889B (en) * 2018-12-26 2021-09-14 百度在线网络技术(北京)有限公司 File system implementation method, device, equipment and storage medium based on block chain
CN110413644A (en) * 2019-06-17 2019-11-05 中国平安人寿保险股份有限公司 A kind of data cache method, electronic device and computer readable storage medium
CN110413644B (en) * 2019-06-17 2023-07-25 中国平安人寿保险股份有限公司 Data caching method, electronic device and computer readable storage medium
WO2022012143A1 (en) * 2020-07-17 2022-01-20 华为技术有限公司 Memory management technology and computer system
CN112948336A (en) * 2021-03-30 2021-06-11 联想凌拓科技有限公司 Data acceleration method, cache unit, electronic device and storage medium
CN117113090A (en) * 2023-10-23 2023-11-24 一网互通(北京)科技有限公司 Data source label marking method and device and electronic equipment
CN117113090B (en) * 2023-10-23 2024-01-19 一网互通(北京)科技有限公司 Data source label marking method and device and electronic equipment

Also Published As

Publication number Publication date
CN106095698B (en) 2019-04-23

Similar Documents

Publication Publication Date Title
CN106095698A (en) OO caching write, read method and device
US10083131B2 (en) Generating and/or employing a descriptor associated with a memory translation table
JP7047228B2 (en) Data query methods, devices, electronic devices, readable storage media, and computer programs
CN105094707A (en) Method and device for storing and reading data
WO2023066268A1 (en) Request processing method, apparatus and system
CN112256457A (en) A shared memory-based data loading acceleration method, device, electronic device and storage medium
CN103514298A (en) Method for achieving file lock and metadata server
WO2021139431A1 (en) Data synchronization method and apparatus for microservice, electronic device and storage medium
CN113569508B (en) Database model construction method and device for data indexing and access based on ID
WO2021008425A1 (en) System startup method and related device
CN115470156A (en) RDMA-based memory use method, system, electronic device and storage medium
CN116991897A (en) A query method and device based on disk storage
CN116932430A (en) Memory access control system for RDMA network cards
WO2023193528A1 (en) File decompression method and apparatus, and electronic device and computer-readable storage medium
CN118277628B (en) Data access control method, device, computer equipment and storage medium
CN105247618B (en) A kind of hard disk performs the method and device of application code
TWI777268B (en) Virtual memory management method and processor
WO2025055385A1 (en) Image storage method and apparatus for page, and device and storage medium
CN118760627A (en) Address updating device and method, processor and chip
US10114864B1 (en) List element query support and processing
CN114329633A (en) Data storage and access method and device and computer equipment
CN115687178A (en) Data access method and related equipment
CN114358936A (en) A smart contract operation method based on microservice blockchain
CN113722574B (en) Android-based user information determination method, device, equipment and storage medium
CN118708542A (en) File system acceleration method, device, equipment, storage medium and program product

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address

Address after: 100080 Beijing Haidian District city Haidian street A Sinosteel International Plaza No. 8 block 5 layer A, C

Patentee after: Youku network technology (Beijing) Co.,Ltd.

Address before: 100080 area a and C, 5 / F, block a, Sinosteel International Plaza, No. 8, Haidian Street, Haidian District, Beijing

Patentee before: 1VERGE INTERNET TECHNOLOGY (BEIJING) Co.,Ltd.

CP03 Change of name, title or address
TR01 Transfer of patent right

Effective date of registration: 20200527

Address after: 310052 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Alibaba (China) Co.,Ltd.

Address before: 100080 area a and C, 5 / F, block a, Sinosteel International Plaza, No. 8, Haidian Street, Haidian District, Beijing

Patentee before: Youku network technology (Beijing) Co.,Ltd.

TR01 Transfer of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20190423

CF01 Termination of patent right due to non-payment of annual fee