WO2013131443A1 - 存储数据的方法及装置 - Google Patents

存储数据的方法及装置 Download PDF

Info

Publication number
WO2013131443A1
WO2013131443A1 PCT/CN2013/072042 CN2013072042W WO2013131443A1 WO 2013131443 A1 WO2013131443 A1 WO 2013131443A1 CN 2013072042 W CN2013072042 W CN 2013072042W WO 2013131443 A1 WO2013131443 A1 WO 2013131443A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
sub
state
block
storage device
Prior art date
Application number
PCT/CN2013/072042
Other languages
English (en)
French (fr)
Inventor
林爱民
唐炯
王军帅
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to MX2014010780A priority Critical patent/MX352050B/es
Priority to JP2014560227A priority patent/JP5851055B2/ja
Priority to EP13757716.9A priority patent/EP2824893B1/en
Priority to BR112014021885-4A priority patent/BR112014021885B1/pt
Priority to KR1020147028190A priority patent/KR101663215B1/ko
Publication of WO2013131443A1 publication Critical patent/WO2013131443A1/zh
Priority to PH12014501932A priority patent/PH12014501932A1/en
Priority to US14/478,151 priority patent/US20150006486A1/en

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/10Address translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • 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/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0871Allocation or management of cache space
    • 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/0804Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with main memory updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/30Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
    • A63F13/35Details of game servers
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/50Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers
    • A63F2300/55Details of game data or player data management
    • A63F2300/5526Game data structure
    • A63F2300/5533Game data structure using program state or machine event data, e.g. server keeps track of the state of multiple players on in a multiple player game
    • 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/12Replacement control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for storing data. Background of the invention
  • the data generated by the service logic when the data generated by the service logic is stored, the data generated by the service logic is transmitted to the network storage device through the network, and is stored by the database on the network storage device.
  • a cache space is established on the network storage device, and data with a relatively high interaction frequency is stored in the cache space.
  • the data may be updated at any time in the game scenario, whether the data generated by the business logic is stored in the cache space of the network storage device or stored in the database, it is necessary to connect to the network storage device through the network multiple times.
  • the network connection itself will result in lower storage efficiency, and will affect the subsequent data interaction efficiency.
  • the data structure in the database is fixed and the scalability is not high, it will not be able to meet the requirements of the business logic to change the data structure.
  • the embodiment of the present invention provides a method and an apparatus for storing data.
  • a method of storing data comprising: Configuring an expandable two-dimensional data cache array in a local shared memory according to a preset configuration policy, the two-dimensional data cache array includes a plurality of logical data blocks, each of the logical data blocks including a plurality of data storage data Sub data block
  • Data on the network storage device is stored in a sub-block corresponding to the data according to business logic requirements.
  • An apparatus for storing data comprising:
  • a configuration module configured to configure, in a local shared memory, an expandable two-dimensional data cache array according to a preset configuration policy, where the two-dimensional data cache array includes multiple logical data blocks, and each of the logical data blocks includes multiple a sub-block of data for storing data;
  • a loading module configured to store data on the network storage device into the corresponding data data block according to the business logic requirement.
  • FIG. 1 is a flowchart of a method for storing data according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of a data storage system according to an embodiment of the present invention
  • FIG. 3 is a storage according to another embodiment of the present invention.
  • Method flow chart of data
  • FIG. 4 is a data state transition diagram provided by an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of a logical data block according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of a mapping relationship table according to an embodiment of the present invention
  • FIG. 7 is a schematic structural diagram of a device for storing data according to an embodiment of the present invention
  • FIG. 8 is a schematic structural diagram of a device for storing data according to an embodiment of the present invention
  • FIG. 9 is a third embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of a device for storing data according to an embodiment of the present invention
  • FIG. 11 is a schematic structural diagram of a fifth device for storing data according to an embodiment of the present invention
  • FIG. 13 is a schematic structural diagram of a device for storing data according to a sixth embodiment of the present invention.
  • FIG. The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
  • An embodiment of the present invention provides a method for storing data. Referring to FIG. 1, the method includes the following steps.
  • a scalable two-dimensional data cache array is configured in the local shared memory according to a preset configuration policy, where the two-dimensional data cache array includes multiple logical data blocks, and each logical data block includes multiple storage blocks. A sub-block of data.
  • step 102 data on the network storage device is stored into the corresponding sub-block according to the business logic requirement.
  • the method further includes: setting a data state for each of the sub-blocks according to the condition of storing data in each of the sub-blocks, the data state It is one of an idle state, a loaded state, a normal state, a modified state, a released state, and a timed released state.
  • the method further includes: modifying data in the sub-block corresponding to the service logic, and synchronizing the modified data to Network storage device.
  • the synchronizing the modified data to the network storage device includes: periodically polling the data status of each sub-block, and synchronizing the data in the sub-block with the data status to the modified state to the network storage device.
  • the method further includes: modifying the data state of the sub-block of the data state to the modified state to a normal state.
  • the method further includes: synchronizing data in the sub-block corresponding to the service logic to the network storage device, and releasing the The shared memory corresponding to the subblock.
  • the data in the corresponding sub-block is synchronized to the network storage device according to the service logic, and specifically includes: querying the data status of each sub-block, and synchronizing the data in the sub-block with the data status to the time-released state to the network.
  • Storage device Further, after synchronizing the data in the sub-block of the data release state to the network storage device, the method further includes: modifying the state of the sub-block of the data state to the time-release state to the idle state.
  • the data on the network storage device is stored in the corresponding sub-block according to the business logic requirement, including: selecting a sub-block with the data state as an idle state in all the sub-blocks, and storing the network according to the business logic requirement
  • the data on the device is stored in the selected sub-block.
  • the method further includes: modifying the data state of the selected sub-block from the idle state to the loaded state State, and after the data is loaded, the data state of the selected sub-block is changed from the loading state to the normal state.
  • the method further includes: establishing a mapping relationship between the two-dimensional data cache array and the network storage device, and according to the two-dimensional data cache array
  • the data change in the child data block updates the mapping relationship table, and the mapping relationship table is stored on the network storage device, and records the data storage condition of each sub-block in each logical data block; wherein, the two-dimensional data cache array
  • Each logical data block corresponds to a mapping relationship table, and the sub data blocks in each logical data block correspond to one record in the mapping relationship table.
  • the method provided in this embodiment configures the scalable two-dimensional data cache array in the local shared memory according to the preset configuration policy, and stores the data on the network storage device to the two-dimensional data cache array according to the business logic requirement.
  • the local storage data is realized, thereby improving the efficiency of data storage and interaction, and since the two-dimensional data cache array storing the data is expandable, the scalability of the data structure is improved, thereby being able to satisfy The requirements of the business logic;
  • the modified data is synchronized to the network storage device, thereby realizing the data synchronization between the local shared memory and the network storage device, thereby effectively preventing data loss.
  • Another embodiment of the present invention provides a method for storing data by configuring an expandable two-dimensional data cache array in a local shared memory, and continuously changing data that changes continuously with system operation, not only by network storage devices.
  • the storage is also stored from the network storage device into the sub-block of the two-dimensional data cache array, thereby realizing local storage and invocation of the data.
  • the present embodiment uses the data storage system shown in FIG. 2 as an example to describe the method provided in this embodiment in detail. Referring to FIG. 3, the method provided in this embodiment includes the following steps.
  • step 301 the configuration is expandable in the local shared memory according to a preset configuration policy.
  • a two-dimensional data cache array comprising a plurality of logical data blocks, each logical data block comprising a plurality of sub-data blocks for storing data.
  • the preset configuration policy is used to configure the number of logical data blocks in the two-dimensional data buffer array and the number and capacity of the sub-data blocks in each logical data block to implement data structure expansion.
  • the extension to the data structure includes an increase or decrease in the number of logical data blocks in the two-dimensional data buffer array, and a number of sub-blocks of each logical data block in the two-dimensional data buffer array. Change in capacity.
  • the configuration policy can be set according to the actual situation. For example, the number of logical data blocks configured in the configuration policy and the number and capacity of the sub-blocks are configured according to the requirements of the data structure of the service logic, or configured by other setting modes. This embodiment does not apply to the preset configuration policy.
  • Local shared memory refers to the large-capacity memory that can be accessed by different central processors in the computer system of the multitasking processor, and the shared memory can be directly read and written to improve the processing efficiency of the processor.
  • a process initiated by the business logic process and the data synchronization agent process is invoked to configure the scalable two-dimensional data cache array in the local shared memory. For example, if the business logic process is started earlier than the data synchronization agent process, the business logic process configures the scalable two-dimensional data cache array in the local shared memory according to the preset configuration policy; if the data synchronization agent process is earlier than the business logic process When started, the data synchronization agent process configures the scalable two-dimensional data cache array in the local shared memory according to the preset configuration policy.
  • the configured two-dimensional data cache array includes a plurality of logical data blocks, each logical data block including a plurality of sub-data blocks for storing data. In order to distinguish sub-blocks in different logical blocks, the sub-blocks can be identified in the form of coordinates. As shown in Figure 2, the N-dimensional data cache array is configured to include N logics. For example, if the data block includes n sub-blocks in each logical block, the n-th data block (N, n) can be used to represent the n-th sub-block in the Nth logical block.
  • each sub-block can be used to store data
  • the logical blocks in the two-dimensional data cache array can be divided into dynamic logical blocks and static logical data blocks according to logical functions.
  • the sub-data blocks in the dynamic logical data block are used to store dynamic data
  • the sub-data blocks in the static logical data block are used to store static data.
  • the dynamic data includes data that can be dynamically loaded, released, and synchronized; the shared memory space corresponding to the sub-blocks for storing the dynamic data can be recycled, such as game player role data in the business logic, and the character's upper and lower lines involve data. Synchronous pull and storage. The static data is not released after a load is completed, and the shared memory is resident.
  • the shared memory space corresponding to the sub-block for storing static data does not need to be released, and the static data is synchronized with the network storage device by using a timing mechanism, for example, Market trading hall data in the game.
  • the logical data block is not limited to a dynamic logical data block or a static logical data block.
  • the configuration may also be configured through a configuration policy.
  • the addresses of the logical data blocks and the sub-blocks are physical addresses in the shared memory, and the business logic processes the process and the data.
  • the address in the synchronous proxy process is a logical address.
  • the process of configuring the two-dimensional data cache array is configured. It is also necessary to map the memory space of the two-dimensional data cache array to its own process memory space, that is, to realize the conversion of the physical address to the logical address. For the process that does not have a two-dimensional data cache array configured, the memory space of the two-dimensional data cache array can be mapped to its own process memory space after startup.
  • the two-dimensional data cache array and the data therein will be protected when the system is uninterrupted and the memory is not manually cleared or destroyed. Continuity and independence. That is to say, once the two-dimensional data cache array configuration is completed, the data structure of the two-dimensional data cache array and the data therein always exist in the case where the system is continuously powered and the memory still exists. However, if the system is powered off, memory is cleared, or corrupted, the configuration of the 2D data cache array needs to be re-executed.
  • a data state is set for each sub-block according to the case of storing data in each sub-block, wherein the data states are in an idle state, a loaded state, a normal state, a modified state, a released state, and a timed released state.
  • the data status where the data status of each sub-block includes, but is not limited to, the following six data states:
  • Timing release After the data release fails, the sub-data block is set to the state, and the data can be released periodically by timing control until the data is released successfully.
  • the data state of the sub-block can be converted between the above six states, and the conversion relationship can be as shown in FIG. 4.
  • the data state is idle, and then according to the change of the data storage. Change the status of the data in a timely manner.
  • Each of the logical data blocks may be composed of a logical data block header and a child data block.
  • the total header of the logical data block is 4 bytes, and the length of the stored data in the logical data block is stored, and each sub-block is composed of the header structure of the sub-block and Data composition
  • the header structure of the sub-block can be as follows:
  • Status //The status of the data, where the key value of the data in the sub-block is the same as the key of the data in the network storage device, that is, whether the data is stored in the local shared memory or stored in the network.
  • the key corresponding to each data is constant, thereby facilitating the search of a data when stored in multiple locations.
  • the two-dimensional data buffer array After the two-dimensional data buffer array is configured, when a sub-block is allocated data, the value of the key, ver, time, status of the sub-block structure is modified correspondingly, and the sub-block is not Allocating, unless the data in the sub-block is released and in the free state; when the data in a sub-block is released, the data of the sub-block is correspondingly cleared, and the key of the sub-block structure is modified. , time, status value.
  • the method provided in this embodiment establishes a two-dimensional data cache array. After that, it also includes: A mapping relationship table between the two-dimensional data cache array and the network storage device is established, and the mapping relationship table is updated according to the data change in the sub-block of the two-dimensional data cache array. The mapping relationship table is stored on the network storage device, and the data storage status of each sub-block in each logical data block is recorded.
  • each logical data block in the two-dimensional data buffer array corresponds to one mapping relationship table
  • the sub-data blocks in each logical data block correspond to one record in the mapping relationship table
  • the established mapping relationship table may be as shown in FIG. 6.
  • One logical data block in the two-dimensional data cache array corresponds to a mapping relationship table stored in the database, and the mapping relationship table records the structure of the logical data block.
  • the sub-blocks in each logical block correspond to one record in the mapping table, and the size of each record is fixed, corresponding to the structural size of the sub-blocks in the logical block.
  • the records in the mapping table corresponding to the sub-block will also be updated correspondingly, that is, after the mapping table is established, the sub-data according to the two-dimensional data cache array needs to be cached.
  • the data changes in the block update the mapping relationship table.
  • step 303 a sub-data block whose data state is an idle state is selected among all the sub-blocks, and data on the network storage device is stored in the selected sub-block according to the business logic requirement.
  • the method provided by the embodiment stores the data on the network storage device to the local share.
  • Memory is stored in a two-dimensional data cache array to enable local storage of data.
  • the storage condition may be identified by the data status, so that the sub-data blocks whose data status is the idle state are selected in all the sub-blocks, and then the data on the network storage device is stored according to the service logic to the selected sub-block of the idle state. in.
  • the business logic process and the data synchronization agent process have realized the conversion of the physical addresses in the shared memory to the respective spatial logical addresses in the two-dimensional data cache array configuration phase, the business logic process and the data synchronization agent process can be known.
  • the sub-block of data that is, the coordinates (N, n) of the sub-block of the data to be loaded, and then the data interface of the device where the service logic process is located sends a corresponding data loading message to the data synchronization agent process through the message queue,
  • the data loading message carries at least the operation type and the identifier of the data to be loaded, so that the data synchronization agent process explicitly performs which operation on which sub-block. Since the step is an operation of loading data, the type of operation carried in the data loading message is loading; and the identifier of the data to be loaded is used to clarify which data in the network storage device is to be loaded. In this embodiment, whether the data is stored on the network storage device or stored in the local shared memory, the key value key is used as the identifier of each data.
  • the data synchronization agent process selects an idle thread in the thread pool, and the idle thread acquires the data to be loaded from the network storage device according to the key value of the data to be loaded carried in the data loading message.
  • the network storage device still stores all the generated data in a database.
  • the data calling frequency in the database is pre-stated, the data is sorted according to the calling frequency from high to low, and the data with high calling frequency is stored in the cache in advance.
  • the thread in the data synchronization agent process can directly read the data to be loaded from the cache space, thereby improving the data reading efficiency.
  • the thread in the data synchronization agent process can also directly operate the database. This embodiment is not specifically limited herein.
  • the data in the data synchronization agent process When the data in the data synchronization agent process acquires the data to be loaded, it first searches for the data to be loaded in the cache space according to the key value of the data to be loaded carried in the data loading message. If the data to be loaded exists in the cache space, the thread passes. The data synchronization interface between the cache space and the data synchronization agent process transfers the data to be loaded to the data synchronization agent process. If there is no data to be loaded in the cache space, the data to be loaded is searched from the database, and the data to be loaded is to be loaded. The data is cached in the cache space, and then the data to be loaded is transferred to the data synchronization agent process through the data synchronization interface between the cache space and the data synchronization agent process.
  • the data synchronization agent process After receiving the data to be loaded, the data synchronization agent process writes the data to be loaded through the data interface of the data synchronization agent process end.
  • the corresponding sub-block that is, in the sub-block corresponding to the coordinates carried in the data loading message.
  • the data state of the sub-block of the data being loaded is changed from the idle state to the loaded state, and after the loading is completed, the data state is changed from the loaded state to the normal state.
  • the operation of loading the data stored on the network storage device into the local shared memory ends, and if the subsequent application needs to call the data or perform other operations on the data, it can be implemented locally without connecting to the network storage device through the network. .
  • the specific modification process is as follows.
  • step 304 the data in the sub-block is modified according to the business logic.
  • the trigger conditions for modifying data are not limited.
  • the game player character data in the business logic the change of the character's online and offline lines, can trigger the modification of the stored data in the sub-block according to the business logic.
  • the service logic process can directly replace the modified data with the stored data in the corresponding sub-block through the data interface of the device where the service logic process is located, and after the modification is completed, the status of the sub-block is normal. The status is modified to modify the status.
  • step 305 the data state of each sub-block is periodically polled, and the data in the sub-block whose data state is the modified state is synchronized to the network storage device.
  • data loss is effectively prevented.
  • data synchronization is performed.
  • the agent process periodically polls the data status of each sub-block and synchronizes the data in the sub-block with the data status to the modified state to the network storage device.
  • the data synchronization agent process periodically polls the data state in the header structure of each sub-block through the data interface of the device where the data synchronization agent process is located, and if the data state of the sub-block is polled, the meaning is changed, that is, meaning The data in the sub-block is the modified data, and the data synchronization agent process obtains the modified data and the key value from the sub-data block through the data interface of the device where the data synchronization agent process is located, and selects in the thread pool.
  • the free thread replaces the modified data with data having the same key value as the modified data in the cache space, and then the network storage device can synchronously store the modified data in the cache space to the instant
  • the update of the cache space can also be checked periodically, and the modified data in a period of time can be synchronously stored in the database.
  • the data synchronization agent process synchronizes the data in the modified data sub-block to the network storage device, and also changes the data state to the modified state.
  • the data state of the sub-block is modified to the normal state operation.
  • the data synchronization timeout period is configured by using a preset configuration policy, and the data synchronization agent process is monitored for data synchronization time. If the data synchronization agent process performs data synchronization for more than the configured data.
  • the data service timeout status code is returned to the service logic process through the data interface of the device where the service logic process is located, and the service logic determines whether to re-synchronize the data.
  • the synchronization operation process is as follows.
  • step 306 according to the business logic, the data in the sub-block is synchronized to the network storage device, and the shared memory corresponding to the sub-block is released.
  • the synchronization operation in this step is different from the synchronization operation in the above step 305 in that the synchronization operation in the above step 305 is performed after the data in the sub-block of the two-dimensional data cache array is modified, in order to ensure local shared memory and
  • the data storage device is triggered by the data consistency, and the synchronization operation in this step is to judge according to the business logic that the data in a certain sub-block of the two-dimensional data cache array does not change continuously with the system operation, but still needs Triggered when it is persisted for storage. And because the data targeted by this step is data that does not change continuously as the system changes, the shared memory occupied by the data can be released.
  • the data interface of the device where the service logic process is located is modified by the service logic process to modify the data state of the sub-block to be released, and the data to be released is about to be released.
  • the data state of the sub-block is changed from the normal state to the released state, and then the data interface passes the message queue to the data.
  • the step proxy process sends a data synchronization release message, where the data synchronization release message carries at least the operation type and the identifier of the data to be released, in addition to the coordinates of the sub-data block carrying the data to be released, so that the data synchronization agent process explicitly identifies which sub-data What the block does.
  • the step is a synchronous release operation
  • the type of operation carried in the data synchronization release message is release; and the identifier of the data to be released is used to clarify which data in the sub-block of the two-dimensional data cache array the data to be released is. .
  • the key value key is used as the identifier of each data.
  • the data synchronization agent process After receiving the data synchronization release message, the data synchronization agent process takes out the data in the sub-data block corresponding to the coordinates carried in the data synchronization release message by calling the data interface of the device where the data synchronization agent process is located, and selects the data in the thread pool.
  • An idle thread is synchronized by the idle thread to the database of the network storage device, and the data is persistently stored by the database.
  • the data interface timing detection data of the device where the service logic process is located is completely released, and if the data is synchronously released, the sub-data corresponding to the coordinates carried in the message body is detected. If there is no data in the block, it is judged that the release is completed, that is, the shared memory occupied by the sub-block is released, and thus the data state of the sub-block is changed from the released state to the idle state, and the sub-block can be allocated and loaded again.
  • the release failure may be determined, that is, The shared memory occupied by the sub-block is not successfully released, and thus the data state of the sub-block is modified from the released state to the time-released state.
  • the size of the preset time is not specifically limited in this embodiment.
  • each sub-number is periodically queried by the data synchronization agent process.
  • the data synchronization agent process is re-triggered to synchronize the data to the network storage device, and the data interface of the device where the business logic process is located
  • the data state of the sub-block is modified from the timing release state to the idle state, so that the sub-block can be allocated load data again.
  • the scalable two-dimensional data cache array is configured in the local shared memory according to the preset configuration policy, and the data on the network storage device is stored to the two-dimensional data cache array according to the business logic requirement.
  • the local storage data is realized, thereby improving the efficiency of data storage and interaction, and since the two-dimensional data cache array storing the data is scalable, the scalability of the data structure is improved, thereby enabling Meet the needs of business logic.
  • the modified data is synchronized to the network storage device, thereby realizing the data synchronization between the local shared memory and the network storage device, thereby effectively preventing data loss.
  • the embodiment of the invention further provides an apparatus for storing data, which is used for executing the method for storing data provided by the above embodiments.
  • the apparatus includes a configuration module 701 and a load module 702.
  • the configuration module 701 is configured to configure an expandable two-dimensional data cache array in the local shared memory according to a preset configuration policy, where the two-dimensional data cache array includes multiple logical data blocks, and each logical data block includes multiple uses. a sub-block of data for storing data;
  • the load module 702 is configured to store data on the network storage device into corresponding sub-blocks according to business logic requirements.
  • the local shared memory refers to a large-capacity memory that can be accessed by different central processing units in the computer system of the multi-tasking processor, and the shared memory can be directly read and written to improve the processing efficiency of the processor.
  • the configuration module 701 configures the expandable two-dimensional in the local shared memory I will not repeat them here.
  • the apparatus can also include a setup module 703.
  • the setting module 703 is configured to set a data state for each sub-block according to a condition of storing data in each sub-block, wherein the data state is in an idle state, a loaded state, a normal state, a modified state, a released state, and a timed release state.
  • the data state is in an idle state, a loaded state, a normal state, a modified state, a released state, and a timed release state.
  • the apparatus can also include a modification module 704 and a modification synchronization module 705.
  • the modification module 704 is configured to modify data in the sub-block according to the business logic.
  • the modify synchronization module 705 is configured to synchronize the modified data of the modification module 704 to the network storage device.
  • the modified synchronization module 705 includes a polling unit 7051 and a modified synchronization unit 7052.
  • the polling unit 7051 is configured to periodically poll the data status of each sub-block.
  • the modification synchronization unit 7052 is configured to synchronize the data in the sub-block of the data state polled by the polling unit 7051 to the modified state to the network storage device.
  • the modification synchronization module 705 further includes a state modification unit 7053 for modifying the data state of the sub-block of the data state to the modified state to a normal state.
  • the apparatus can also include a release synchronization module 706 and a release module 707.
  • the release synchronization module 706 is configured to synchronize data in the corresponding sub-block to the network storage device according to the service logic.
  • the release module 707 is configured to release the shared memory corresponding to the sub-block after the synchronization module 706 synchronizes the data in the corresponding sub-block to the network storage device according to the service logic.
  • the release synchronization module 706 includes a query unit 7061 and a release synchronization unit 7062.
  • the query unit 7061 is configured to query data of each sub-block Status.
  • the release synchronization unit 7062 is configured to synchronize data in the sub-block of the data state queried by the query unit 7061 to the network storage device.
  • the release synchronization module 706 further includes a state modification unit 7063 for modifying the state of the sub-data block whose data state is the timing release state to the idle state.
  • the load module 702 includes a selection unit 7021 and a load unit 7022.
  • the selecting unit 7021 is configured to select a sub-block of data in which all data sectors are in an idle state among all sub-blocks.
  • the loading unit 7022 is configured to store data on the network storage device into the sub-blocks selected by the selecting unit according to the business logic requirements.
  • the loading module 702 further includes a state modifying unit 7023, configured to modify the data state of the selected sub-block from the idle state to the loading state, and after the data is loaded, select the data state of the selected sub-block. Changed from the loading state to the normal state.
  • the apparatus further includes a setup module 708 and an update module 709.
  • the establishing module 708 is configured to establish a mapping relationship between the two-dimensional data cache array and the network storage device, where the mapping relationship table is stored on the network storage device, and the data storage status of each sub-block in each logical data block is recorded.
  • the update module 709 is configured to update the mapping relationship table established by the module 707 based on the data changes in the sub-blocks of the two-dimensional data cache array.
  • Each logical data block in the two-dimensional data cache array corresponds to a mapping relationship table, and the sub-data blocks in each logical data block correspond to one record in the mapping relationship table.
  • the scalable two-dimensional data cache array is configured in the local shared memory according to a preset configuration policy, and the data on the network storage device is stored to the two-dimensional data cache array according to the business logic requirement.
  • the implementation of this The data is stored to improve the efficiency of data storage and interaction, and since the two-dimensional data cache array storing the data is scalable, the scalability of the data structure is improved, thereby meeting the requirements of the business logic.
  • the modified data is synchronized to the network storage device, thereby realizing the data synchronization between the local shared memory and the network storage device, thereby effectively preventing data loss.
  • the data storage device provided by the foregoing embodiment stores data
  • only the division of each functional module is described.
  • the function distribution may be completed by different functional modules as needed.
  • the internal structure of the device is divided into different functional modules to perform all or part of the functions described above.
  • the device for storing data and the method for storing data provided by the above embodiments are in the same concept, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • the methods and apparatus provided by the embodiments of the present invention may be implemented by hardware, or computer readable instructions, or a combination of hardware and computer readable instructions.
  • the computer readable instructions used in this embodiment are stored by a plurality of processors in a readable storage medium such as a hard disk, a CD-ROM, a DVD, an optical disk, a floppy disk, a magnetic tape, a RAM, a ROM, or other suitable storage device.
  • a readable storage medium such as a hard disk, a CD-ROM, a DVD, an optical disk, a floppy disk, a magnetic tape, a RAM, a ROM, or other suitable storage device.
  • at least some of the computer readable instructions may be replaced by specific hardware, such as custom integrated circuits, gate arrays, FPGAs, PLDs, and computers with specific functions, and the like.
  • Embodiments of the present invention provide a computer readable storage medium for storing instructions for causing a computer to perform the methods described herein.
  • the system or device provided by this embodiment has a storage medium in which computer readable program code is stored for implementing the functions of any of the above embodiments, and these systems or devices (or CPUs or MPUs) can read and Execute the program code stored on the storage medium.
  • the program code read from the storage medium can implement any of the above embodiments, and thus the program code and the storage medium storing the program code are a part of the technical solution.
  • Storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (eg, CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), disks, Flash card, ROM, etc.
  • the program code can also be downloaded from the server computer via the communication network.
  • an operation at least partially implemented by the program code may be implemented by an operating system running on a computer, thereby implementing the technical solution of any of the above embodiments, wherein the computer is executed based on the program code. instruction.
  • the program code in the storage medium is written to the memory, wherein the memory is located in an expansion board inserted in the computer or in an expansion unit connected to the computer.
  • the CPU in the expansion board or the expansion unit performs at least part of the operation based on the program code according to the instruction, thereby implementing the technical solution of any of the above embodiments.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明实施例公开了一种存储数据的方法及装置。该方法包括:根据预设的配置策略在本地共享内存中配置可扩展的二维数据缓存阵列,二维数据缓存阵列包括多个逻辑数据块,每个逻辑数据块包括多个用于存储数据的子数据块;根据业务逻辑需求,将网络存储设备上的数据存储至对应的子数据块中。应用本发明实施例,能够实现本地存储数据,从而可以提高数据存储及交互的效率,且由于存储数据的二维数据缓存阵列为可扩展的,因而提高了数据结构的可扩展性,从而能够满足业务逻辑的需求。

Description

存储数据的方法及装置
技术领域
本发明涉及计算机技术领域,特别涉及一种存储数据的方法及装置。 发明背景
随着游戏市场的蓬勃发展, 游戏的种类层出不穷, 参与游戏的人数 也逐渐从单人发展到多人。 随着人数的增多, 游戏产生的数据量也逐渐 加大, 业务逻辑也随之变得更为复杂。 如何高效地存储业务逻辑产生的 数据, 以向用户提供更好的服务, 成为了游戏厂家十分关注的问题。
在现有技术中, 在存储业务逻辑产生的数据时, 将业务逻辑产生的 数据通过网络传输到网络存储设备上, 并由该网络存储设备上的数据库 进行存储。 并且为了加快数据交互的速度, 该网络存储设备上建立了緩 存空间, 交互频率比较高的数据被存储在该緩存空间。
但是, 由于在游戏场景中, 随时都可能发生数据的更新, 无论将业 务逻辑产生的数据存储在网络存储设备的緩存空间中还是存储在数据 库中, 均需要多次通过网络连接至网络存储设备, 而网络连接本身就会 导致存储效率的降低, 还将影响后续的数据交互效率; 同时, 如果数据 库中的数据结构固定, 可扩展性不高, 将无法满足业务逻辑要求数据结 构变更的需求。 发明内容
为了在提高数据存储效率的同时, 提高数据结构的可扩展性, 以满 足业务逻辑的需求, 本发明实施例提供了一种存储数据的方法及装置。
一种存储数据的方法, 所述方法包括: 根据预设的配置策略在本地共享内存中配置可扩展的二维数据緩存 阵列, 所述二维数据緩存阵列包括多个逻辑数据块, 每个所述逻辑数据 块包括多个用于存储数据的子数据块;
根据业务逻辑需求, 将网络存储设备上的数据存储至所述数据对应 的子数据块中。
一种存储数据的装置, 所述装置包括:
配置模块, 用于根据预设的配置策略在本地共享内存中配置可扩展 的二维数据緩存阵列, 所述二维数据緩存阵列包括多个逻辑数据块, 每 个所述逻辑数据块包括多个用于存储数据的子数据块;
加载模块, 用于根据业务逻辑需求, 将网络存储设备上的数据存储 至所述数据对应的子数据块中。
本发明实施例提供的技术方案的有益效果是:
通过根据预设的配置策略在本地共享内存中配置可扩展的二维数据 緩存阵列, 并根据业务逻辑需求, 将网络存储设备上的数据存储至二维 数据緩存阵列的对应的子数据块中, 实现本地存储数据, 从而可以提高 数据存储及交互的效率, 且由于存储数据的二维数据緩存阵列为可扩展 的, 因而提高了数据结构的可扩展性, 从而能够满足业务逻辑的需求; 另外, 在子数据块中的数据修改后, 通过将修改后的数据同步至网络存 储设备, 进而实现本地共享内存与网络存储设备的数据同步, 有效防止 数据丟失。 附图简要说明
为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例描 述中所需要使用的附图作筒单地介绍, 显而易见地, 下面描述中的附图 仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出 创造性劳动的前提下, 还可以根据这些附图获得其他的附图。
图 1是本发明实施例提供的一种存储数据的方法流程图; 图 2是本发明实施例提供的一种数据存储系统的结构示意图; 图 3是本发明另一实施例提供的一种存储数据的方法流程图; 图 4是本发明实施例提供的一种数据状态转换图;
图 5是本发明实施例提供的一种逻辑数据块的结构示意图; 图 6是本发明实施例提供的一种映射关系表示意图;
图 7是本发明实施例提供的第一种存储数据的装置结构示意图; 图 8是本发明实施例提供的第二种存储数据的装置结构示意图; 图 9是本发明实施例提供的第三种存储数据的装置结构示意图; 图 10是本发明实施例提供的第四种存储数据的装置结构示意图; 图 11是本发明实施例提供的第五种存储数据的装置结构示意图; 图 12是本发明实施例提供的第六种存储数据的装置结构示意图; 图 13是本发明实施例提供的第七种存储数据的装置结构示意图。 实施本发明的方式 为使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图对 本发明实施方式作进一步地详细描述。
本发明实施例提供了一种存储数据的方法, 参见图 1 , 该方法包括 如下步骤。
在步骤 101中, 根据预设的配置策略在本地共享内存中配置可扩展 的二维数据緩存阵列, 该二维数据緩存阵列包括多个逻辑数据块, 每个 逻辑数据块包括多个用于存储数据的子数据块。
在步骤 102中, 根据业务逻辑需求, 将网络存储设备上的数据存储 至对应的子数据块中。 进一步地, 根据预设的配置策略在本地共享内存中配置可扩展的二 维数据緩存阵列之后, 还包括: 根据每个子数据块中存储数据的情况为 每个子数据块设置数据状态, 该数据状态为空闲状态、 加载状态、 正常 状态、 修改状态、 释放状态和定时释放状态中的一种。
进一步地, 根据业务逻辑需求, 将网络存储设备上的数据存储至对 应的子数据块中之后, 还包括: 修改与该业务逻辑对应的子数据块中的 数据, 并将修改后的数据同步至网络存储设备。 其中, 将修改后的数据 同步至网络存储设备, 包括: 定时轮询每个子数据块的数据状态, 将数 据状态为修改状态的子数据块中的数据同步至网络存储设备。 进一步 地, 将数据状态为修改状态的子数据块中的数据同步至网络存储设备之 后, 还包括: 将数据状态为修改状态的子数据块的数据状态修改为正常 状态。
进一步地, 根据业务逻辑需求, 将网络存储设备上的数据存储至对 应的子数据块中之后, 还包括: 将与该业务逻辑对应的子数据块中的数 据同步至网络存储设备, 并释放该子数据块对应的共享内存。 其中, 根 据业务逻辑将对应的子数据块中的数据同步至网络存储设备, 具体包 括: 查询每个子数据块的数据状态, 并将数据状态为定时释放状态的子 数据块中的数据同步至网络存储设备。 进一步地, 将数据状态为定时释 放状态的子数据块中的数据同步至网络存储设备之后, 还包括: 将数据 状态为定时释放状态的子数据块的状态修改为空闲状态。
其中, 根据业务逻辑需求, 将网络存储设备上的数据存储至对应的 子数据块中, 包括: 在所有子数据块中选择数据状态为空闲状态的子数 据块, 根据业务逻辑需求, 将网络存储设备上的数据存储至选择的子数 据块中。 进一步地, 将网络存储设备上的数据存储至选择的子数据块中 之后, 还包括: 将选择的子数据块的数据状态由空闲状态修改为加载状 态, 并在数据加载完毕后, 将选择的子数据块的数据状态由加载状态修 改为正常状态。
进一步地, 根据预设的配置策略在本地共享内存中配置可扩展的二 维数据緩存阵列之后, 还包括: 建立二维数据緩存阵列与网络存储设备 的映射关系表, 并根据二维数据緩存阵列的子数据块中的数据变化更新 映射关系表, 映射关系表存储在网络存储设备上, 并记录了每个逻辑数 据块中的各个子数据块的数据存储情况; 其中, 二维数据緩存阵列中的 每个逻辑数据块对应一个映射关系表, 每个逻辑数据块中的子数据块对 应映射关系表中的一条记录。
本实施例提供的方法, 通过根据预设的配置策略在本地共享内存中 配置可扩展的二维数据緩存阵列, 并根据业务逻辑需求, 将网络存储设 备上的数据存储至二维数据緩存阵列的对应的子数据块中, 实现本地存 储数据, 从而可以提高数据存储及交互的效率, 且由于存储数据的二维 数据緩存阵列为可扩展的, 因而提高了数据结构的可扩展性, 从而能够 满足业务逻辑的需求; 另外, 在子数据块中的数据修改后, 通过将修改 后的数据同步至网络存储设备, 进而实现本地共享内存与网络存储设备 的数据同步, 有效防止数据丟失。
本发明另一实施例提供了一种存储数据的方法, 该方法通过在本地 共享内存中配置可扩展的二维数据緩存阵列, 对于随系统运行变化而持 续变化的数据, 不仅由网络存储设备进行存储, 还将其从网络存储设备 上存储至该二维数据緩存阵列的子数据块中, 从而实现数据的本地存储 及调用。 为了便于说明, 结合上述实施例的内容, 本实施例以图 2所示 的数据存储系统为例, 对本实施例提供的方法进行详细地举例说明。 参 见图 3 , 本实施例提供的方法包括如下步骤。
在步骤 301中, 根据预设的配置策略在本地共享内存中配置可扩展 的二维数据緩存阵列, 该二维数据緩存阵列包括多个逻辑数据块, 每个 逻辑数据块包括多个用于存储数据的子数据块。
其中, 预设的配置策略用于对二维数据緩存阵列中的逻辑数据块个 数以及每个逻辑数据块中的子数据块个数和容量进行配置, 从而实现对 数据结构扩展。 在本发明实施例中, 对数据结构的扩展包括对二维数据 緩存阵列中的逻辑数据块数量的增减变更, 以及对二维数据緩存阵列中 每个逻辑数据块的子数据块个数和容量的增减变更。 具体实现时, 该配 置策略可根据实际情况设置。 例如, 根据业务逻辑对数据结构的需求设 置配置策略中配置的逻辑数据块个数以及子数据块的个数和容量, 或采 用其他设置方式进行配置, 本实施例不对预设的配置策略中所配置的逻 辑数据块个数以及子数据块个数和容量进行限定。 本地共享内存是指在 多任务处理器的计算机系统中, 可以被不同中央处理器访问的大容量内 存, 且该共享内存可直接读写, 以提高处理器的处理效率。
本步骤中, 可以结合图 2所示的数据存储系统的结构, 调用业务逻 辑进程和数据同步代理进程中先启动的一个进程来在本地共享内存中 配置可扩展的二维数据緩存阵列。 例如, 如果业务逻辑进程较数据同步 代理进程先启动, 则由业务逻辑进程根据预设的配置策略在本地共享内 存中配置可扩展的二维数据緩存阵列; 如果数据同步代理进程较业务逻 辑进程先启动, 则由数据同步代理进程根据预设的配置策略在本地共享 内存中配置可扩展的二维数据緩存阵列。 无论哪个进程执行上述配置操 作, 都需要先根据预设的配置策略申请本地共享内存, 之后再在申请的 本地共享内存中配置二维数据緩存阵列。 配置的二维数据緩存阵列包括 多个逻辑数据块, 每个逻辑数据块包括多个用于存储数据的子数据块。 为了区别不同的逻辑数据块中的子数据块, 可采用坐标的形式对子数据 块进行标识。 如图 2所示, 以配置的二维数据緩存阵列中包括 N个逻辑 数据块、 每个逻辑数据块中包括 n个子数据块为例, 则可用二维数据坐 标( N, n )表示第 N个逻辑数据块中的第 n个子数据块。
进一步地, 无论以何种方式标识子数据块, 每个子数据块均可用于 存储数据, 且二维数据緩存阵列中的逻辑数据块按照逻辑功能可分为动 态逻辑数据块和静态逻辑数据块, 动态逻辑数据块中的子数据块用于存 储动态数据, 静态逻辑数据块中的子数据块用于存储静态数据。 其中, 动态数据包括可动态加载、 释放和同步的数据; 用于存储动态数据的子 数据块对应的共享内存空间可循环使用, 比如业务逻辑中的游戏玩家角 色数据, 角色的上下线就涉及数据的同步拉取和存储。 静态数据在一次 加载完成后始终不被释放, 常驻共享内存, 因而用于存储静态数据的子 数据块对应的共享内存空间无需释放, 且静态数据采用定时机制与网络 存储设备进行数据同步, 比如游戏中的市场交易大厅数据。 在本实施例 中不对逻辑数据块为动态逻辑数据块还是静态逻辑数据块进行限定, 实 际应用中, 也可通过配置策略进行配置。
另外, 在配置得到二维数据緩存阵列后, 由于二维数据緩存阵列配 置在共享内存中, 其中的逻辑数据块和子数据块的地址均为共享内存中 的物理地址, 而业务逻辑处理进程及数据同步代理进程中的地址为逻辑 地址, 为了后续能够通过业务逻辑处理进程及数据同步代理进程对配置 的二维数据緩存阵列中的数据进行操作, 配置该二维数据緩存阵列的进 程在配置结束后, 还需要将二维数据緩存阵列的内存空间映射到自身进 程内存空间, 即实现物理地址到逻辑地址的转化。 对于未配置二维数据 緩存阵列的那个进程, 可在启动后将二维数据緩存阵列的内存空间映射 到自身进程内存空间。
需要说明的是, 当二维数据緩存阵列被配置后, 在系统不断电、 内 存不被手动清除或破坏的情况下, 二维数据緩存阵列及其中的数据将保 持连续性和独立性。 也就是说, 一旦二维数据緩存阵列配置完成, 在系 统不断电、 内存仍然存在的情况下, 该二维数据緩存阵列的数据结构以 及其中的数据一直存在。 但如果系统断电、 内存被清除或是破坏, 需要 重新执行二维数据緩存阵列的配置过程。 对于业务逻辑进程与数据同步 代理进程, 无论系统是否断电、 内存是否被修改或破坏, 如果业务逻辑 进程或数据同步代理进程被重新启动, 均需要重新执行将物理地址转换 成逻辑地址的过程。
在步骤 302中, 根据每个子数据块中存储数据的情况, 为每个子数 据块设置数据状态, 其中, 数据状态为空闲状态、 加载状态、 正常状态、 修改状态、 释放状态和定时释放状态中的一种。
具体地, 在步骤 301中得到配置的二维数据緩存阵列之后, 为了明 确每个子数据块中存储数据的情况, 在本步骤中根据每个子数据块中存 储数据的情况, 为每个子数据块设置数据状态, 其中, 每个子数据块的 数据状态包括但不限于如下 6种数据状态:
1、 空闲 (free): 待分配数据;
2、 加载 (loading): 数据加载中;
3、 正常 (normal): 数据加载完毕;
4、 修改 (modify): 数据被修改;
5、 释放 (remove): 数据存储并释放中;
6、 定时释放 (tick_remove): 数据释放失败后, 将子数据块置为本状 态, 即可通过定时控制, 定时释放该数据, 直到数据释放成功。
在数据存储及更新的过程中, 子数据块的数据状态可在上述 6种状 态之间进行转化, 转化关系可如图 4所示。 对于二维数据緩存阵列中的 子数据块而言, 在二维数据緩存阵列初始配置完成时, 由于子数据块中 还未存储数据, 则其数据状态为空闲状态, 之后再根据数据存储的变化 情况及时更改数据状态。
在对每个子数据块设置完数据状态后, 完成了二维数据緩存阵列的 所有配置。 其中每个逻辑数据块可由逻辑数据块总头及子数据块组成。 以图 5所示的逻辑数据块的结构为例, 逻辑数据块的总头为 4个字节, 用于存放该逻辑数据块中存储数据的长度, 每个子数据块由子数据块的 头结构及数据组成, 子数据块的头结构可如下所示:
header
Key //数据对应的键值 key
Ver 〃数据版本号
Time //数据修改时间
Status //数据的状态 其中, 数据在子数据块中的键值 key与该数据在网络存储设备中的 key是一致的, 也就是说, 无论数据是存储在本地共享内存中, 还是存 储在网络存储设备中, 每个数据对应的 key是不变的, 由此便于一个数 据在多个位置存储时的查找。 且在配置完二维数据緩存阵列后, 当一个 子数据块被分配了数据时, 则相应修改该子数据块头结构的 key, ver, time, status的值, 且该子数据块不会被再次分配, 除非该子数据块中的 数据被释放并且为 free状态; 当一个子数据块中的数据被释放时, 则相 应清除该子数据块的数据, 并修改该子数据块头结构的 key, ver, time, status的值。
进一步地, 由于二维数据緩存阵列中的子数据块用于存储数据, 为 了保证本地共享内存中的数据与网络存储设备上的数据保持同步, 本实 施例提供的方法在建立二维数据緩存阵列后, 还包括: 建立二维数据緩存阵列与网络存储设备的映射关系表, 并根据二维 数据緩存阵列的子数据块中的数据变化更新映射关系表。 该映射关系表 存储在网络存储设备上, 并记录了每个逻辑数据块中的各个子数据块的 数据存储情况。
在本实施例中, 二维数据緩存阵列中的每个逻辑数据块对应一个映 射关系表, 每个逻辑数据块中的子数据块对应映射关系表中的一条记 录。
具体地, 建立的映射关系表可如图 6所示, 二维数据緩存阵列中的 一个逻辑数据块对应存储在数据库中的一个映射关系表, 该映射关系表 记录了该逻辑数据块的结构, 每个逻辑数据块中的子数据块对应映射关 系表中的一条记录, 而且每条记录的大小是固定的, 与逻辑数据块中的 子数据块的结构大小对应。 又由于子数据块中的数据有时会发生变化, 因而与该子数据块对应的映射关系表中的记录也将对应更新, 即在建立 映射关系表之后, 需要根据二维数据緩存阵列的子数据块中的数据变化 更新映射关系表。
至此, 通过上述步骤 301至步骤 302的配置操作, 为数据的本地存 储以及交互提供了配置保障。
在步骤 303中, 在所有子数据块中选择数据状态为空闲状态的子数 据块, 根据业务逻辑需求, 将网络存储设备上的数据存储至选择出的子 数据块中。
在本步骤中, 为了避免每次都通过网络连接至网络存储设备来存储 数据以及进行数据交互带来的效率低下的问题, 本实施例提供的方法通 过将网络存储设备上的数据存储至本地共享内存的二维数据緩存阵列 中, 从而实现数据的本地存储。 且在将网络存储设备上的数据存储至本 地共享内存时, 需要先确定空闲的内存, 由于每个子数据块中的数据存 储情况可由数据状态来标识, 因而在所有子数据块中选择数据状态为空 闲状态的子数据块, 再根据业务逻辑确定将网络存储设备上的哪些数据 存储至选择出的空闲状态的子数据块中。 接下来, 结合图 2所示的数据 系统结构, 对该步骤的具体加载过程进行详细描述。
在图 2中, 由于业务逻辑进程和数据同步代理进程在二维数据緩存 阵列配置阶段已实现了共享内存中的物理地址到各自空间逻辑地址的 转化, 因而业务逻辑进程和数据同步代理进程可以获知二维数据緩存阵 列中的各个子数据块的地址。 根据业务逻辑确定需要将网络存储设备上 的数据存储至本地共享内存时, 业务逻辑进程通过该业务逻辑进程所在 设备的数据接口在二维数据緩存阵列的所有子数据块中选择数据状态 为空闲状态的子数据块, 即得到待加载数据的子数据块的坐标(N, n ), 之后再由该业务逻辑进程所在设备的数据接口通过消息队列向数据同 步代理进程发送对应的数据加载消息, 该数据加载消息中除了携带选择 出的子数据块的坐标, 至少还携带操作类型以及待加载数据的标识, 以 使数据同步代理进程明确对哪个子数据块执行何种操作。 由于该步骤是 加载数据的操作, 因此, 该数据加载消息中携带的操作类型为加载; 而 待加载数据的标识用于明确该待加载数据为网络存储设备中的哪个数 据。 在本实施例中, 无论数据在网络存储设备上存储, 还是在本地共享 内存中存储, 均采用键值 key作为每个数据的标识。
数据同步代理进程接收到该数据加载消息后, 在线程池中选择一个 空闲线程, 由该空闲线程根据该数据加载消息中携带的待加载数据的键 值 key从网络存储设备获取待加载的数据。 本实施例中, 网络存储设备 仍然以数据库来存储产生的所有数据。 为了提高数据存储及交互的效 率, 本实施例中预先对数据库中的数据调用频率进行统计, 将数据按照 调用频率从高到低的顺序排序, 并预先将调用频率高的数据存储在緩存 空间中, 则使数据同步代理进程中的线程可直接从緩存空间中读取待加 载的数据, 进而提高数据的读取效率。 当然, 在系统性能允许的情况下, 数据同步代理进程中的线程也可直接操作数据库, 本实施例在此不作具 体限定。
数据同步代理进程中的线程在获取待加载数据时, 先根据数据加载 消息中携带的待加载数据的键值 key在緩存空间中查找待加载数据, 如 果緩存空间中存在该待加载数据, 则通过緩存空间与数据同步代理进程 之间的数据同步接口将该待加载数据传送给数据同步代理进程, 如果緩 存空间中不存在待加载数据, 则从数据库中查找该待加载数据, 并将该 待加载数据緩存在緩存空间中, 之后再通过緩存空间与数据同步代理进 程之间的数据同步接口将该待加载数据传送给数据同步代理进程。 无论 是从緩存空间中直接查找到待加载数据, 还是从数据库中查找到待加载 数据, 数据同步代理进程在接收到待加载数据后, 通过数据同步代理进 程端的数据接口将该待加载数据写入对应的子数据块中, 即数据加载消 息中携带的坐标所对应的子数据块中。 在数据加载过程中, 将该正在加 载数据的子数据块的数据状态由空闲状态修改为加载状态, 并在加载完 成后, 再将数据状态由加载状态修改为正常状态。 至此, 将网络存储设 备上存储的数据加载到本地共享内存的操作结束, 如果后续应用需要调 用该数据或对该数据进行其他操作, 即可在本地实现, 而无需再通过网 络连接至网络存储设备。 对于加载在本地共享内存中的数据, 如果由于 业务逻辑需要修改, 具体的修改流程详见如下步骤。
在步骤 304中, 根据业务逻辑修改子数据块中的数据。
在本步骤中, 由于存储在本地共享内存中的数据随系统运行变化而 持续变化, 因而在后续数据交互过程中, 更新的可能性也比较大, 也因 为如此, 子数据块中存储的数据被修改的情况也将时常发生, 本实施例 不对修改数据的触发条件进行限定。 例如, 业务逻辑中的游戏玩家角色 数据, 角色的上下线发生变化, 均可触发根据业务逻辑修改子数据块中 已存储的数据。 具体修改时, 业务逻辑进程可通过业务逻辑进程所在设 备的数据接口将修改后的数据直接替换对应的子数据块中已存储的数 据,并在修改完成后,将该子数据块的状态由正常状态修改为修改状态。
在步骤 305中, 定时轮询每个子数据块的数据状态, 将数据状态为 修改状态的子数据块中的数据同步至网络存储设备。
具体地, 在二维数据緩存阵列的子数据块中的数据被修改后, 为了 使本地共享内存与网络存储设备之间保持数据同步, 进而有效防止数据 丟失, 在本实施例中, 由数据同步代理进程定时轮询每个子数据块的数 据状态, 并将数据状态为修改状态的子数据块中的数据同步至网络存储 设备。 在具体实现时, 数据同步代理进程通过数据同步代理进程所在设 备的数据接口定时轮询每个子数据块的头结构中的数据状态, 如果轮询 到子数据块的数据状态为修改状态, 即意味着该子数据块中的数据为修 改后的数据, 数据同步代理进程通过数据同步代理进程所在设备的数据 接口从该子数据块中获取修改后的数据及键值 key, 并在线程池中选择 一个空闲的线程, 由该空闲的线程将该修改后的数据替换緩存空间中与 该修改后的数据具有相同键值 key的数据, 之后网络存储设备可将緩存 空间中修改的数据即刻同步存储到数据库中, 也可定时检查緩存空间的 更新情况, 将一段时间内修改的数据一次性同步存储到数据库中。
为了避免后续步骤将同一修改后的数据重复同步至网络存储设备, 数据同步代理进程将数据状态为修改状态的子数据块中的数据同步至 网络存储设备之后, 还将该数据状态为修改状态的子数据块的数据状态 修改为正常状态的操作。
进一步地,当二维数据緩存阵列的子数据块中的数据频繁地被修改, 需要频繁地将其同步至网络存储设备时, 如果数据同步代理进程来不及 响应, 就会出现数据同步超时的现象。 针对该种情况, 在本实施例中, 通过预设的配置策略来配置数据同步超时时间, 并监控数据同步代理进 程进行数据同步的时间, 如果数据同步代理进程进行数据同步的时间超 过配置的数据同步超时时间, 则通过业务逻辑进程所在设备的数据接口 向业务逻辑进程返回数据业务超时状态码, 由业务逻辑决定是否重新进 行数据同步。
另外, 除了由于子数据块中的数据被修改而触发执行数据同步操作 外, 根据业务逻辑, 可能二维数据緩存阵列的子数据块中的数据不再随 系统运行变化而持续变化了, 但仍需持久化存储。 针对该种情况, 为了 实现持久化存储, 仍需要执行数据同步操作, 该种情况下的同步操作过 程详见如下步骤。
在步骤 306中, 根据业务逻辑, 将子数据块中的数据同步至网络存 储设备, 并释放该子数据块对应的共享内存。
本步骤中的同步操作与上述步骤 305中的同步操作的不同点在于, 上述步骤 305中的同步操作是在二维数据緩存阵列的子数据块中的数据 被修改后, 为了保证本地共享内存与网络存储设备的数据一致性而触发 的, 而本步骤中的同步操作是在根据业务逻辑判断二维数据緩存阵列的 某个子数据块中的数据不再随系统运行变化而持续变化, 但仍需要将其 持久化存储的情况下触发的。 且由于该步骤针对的数据是不再随系统运 行变化而持续变化的数据, 因而可释放该类数据占用的共享内存。
具体实现时,如图 2所示,在业务逻辑需要存储并释放内存空间时, 通过业务逻辑进程调用业务逻辑进程所在设备的数据接口修改待释放 数据的子数据块的数据状态, 即将待释放数据的子数据块的数据状态由 正常状态修改为释放状态, 之后再由该数据接口通过消息队列向数据同 步代理进程发送数据同步释放消息 , 该数据同步释放消息中除了携带待 释放数据的子数据块的坐标, 至少还携带操作类型以及待释放数据的标 识, 以使数据同步代理进程明确对哪个子数据块执行何种操作。 由于该 步骤是同步释放操作, 因此, 该数据同步释放消息中携带的操作类型为 释放; 而待释放数据的标识用于明确该待释放数据为二维数据緩存阵列 的哪个子数据块中的数据。 在本实施例中, 无论数据在网络存储设备上 存储, 还是在本地共享内存中存储, 均采用键值 key作为每个数据的标 识。
数据同步代理进程接收到数据同步释放消息后, 通过调用数据同步 代理进程所在设备的数据接口将该数据同步释放消息中携带的坐标所 对应的子数据块中的数据取出, 并在线程池中选择一个空闲的线程, 由 该空闲的线程将取出的数据同步至网络存储设备的数据库中, 由数据库 持久化存储该数据。
进一步地, 在数据同步代理进程执行数据同步释放的过程中, 业务 逻辑进程所在的设备的数据接口定时检测数据是否释放完毕, 如果检测 到该数据同步释放消息体中携带的坐标所对应的子数据块中没有数据, 则判断释放完毕, 即该子数据块所占用的共享内存被释放, 因而将该子 数据块的数据状态由释放状态修改为空闲状态, 则该子数据块可再次被 分配加载数据; 如果检测到该数据同步释放消息体中携带的坐标所对应 的子数据块中还有数据, 则判断释放未结束, 但如果预设时间后释放还 未结束, 则可判断释放失败, 即该子数据块所占用的共享内存未被成功 释放, 因而将该子数据块的数据状态由释放状态修改为定时释放状态。 其中, 关于预设时间的大小, 本实施例不做具体限定。
对于数据状态为定时释放的子数据块, 为了成功释放该子数据块占 用的共享内存, 在本实施例中, 由数据同步代理进程定时查询每个子数 据块的数据状态, 如果查询到存在数据状态为定时释放状态的子数据 块, 则重新触发数据同步代理进程将其中的数据同步至网络存储设备的 步骤, 且在业务逻辑进程所在设备的数据接口检测成功释放该数据状态 为定时释放状态的子数据块中的数据之后, 将该子数据块的数据状态由 定时释放状态修改为空闲状态, 从而使该子数据块可再次被分配加载数 据。
根据本实施例提供的方法, 通过根据预设的配置策略在本地共享内 存中配置可扩展的二维数据緩存阵列, 并根据业务逻辑需求, 将网络存 储设备上的数据存储至二维数据緩存阵列的对应的子数据块中, 实现本 地存储数据, 从而可以提高数据存储及交互的效率, 且由于存储数据的 二维数据緩存阵列为可扩展的, 因而提高了数据结构的可扩展性, 从而 能够满足业务逻辑的需求。 另外, 在子数据块中的数据修改后, 通过将 修改后的数据同步至网络存储设备, 进而实现本地共享内存与网络存储 设备的数据同步, 有效防止数据丟失。
本发明实施例还提供了一种存储数据的装置, 该装置用于执行上述 实施例所提供的存储数据的方法。 参见图 7, 该装置包括配置模块 701 和加载模块 702。
其中, 配置模块 701用于根据预设的配置策略在本地共享内存中配 置可扩展的二维数据緩存阵列, 该二维数据緩存阵列包括多个逻辑数据 块, 每个逻辑数据块包括多个用于存储数据的子数据块;
加载模块 702用于根据业务逻辑需求, 将网络存储设备上的数据存 储至对应的子数据块中。
其中, 本地共享内存是指在多任务处理器的计算机系统中, 可以被 不同中央处理器访问的大容量内存, 且该共享内存可直接读写, 以提高 处理器的处理效率。 配置模块 701在本地共享内存中配置可扩展的二维 此处不再赘述。
参见图 8,该装置还可以包括设置模块 703。设置模块 703用于根据 每个子数据块中存储数据的情况,为每个子数据块设置数据状态,其中, 数据状态为空闲状态、 加载状态、 正常状态、 修改状态、 释放状态和定 时释放状态中的一种。 该设置模块 703设置数据状态的具体方式详见上 述实施例中步骤 302的相关描述, 此处不再赘述。
参见图 9,该装置还可以包括修改模块 704和修改同步模块 705。其 中, 修改模块 704用于根据业务逻辑修改子数据块中的数据。 修改同步 模块 705用于将修改模块 704修改后的数据同步至网络存储设备。
参见图 10, 修改同步模块 705包括轮询单元 7051和修改同步单元 7052。 其中, 轮询单元 7051 用于定时轮询每个子数据块的数据状态。 修改同步单元 7052用于将轮询单元 7051轮询到的数据状态为修改状态 的子数据块中的数据同步至网络存储设备。进一步地,修改同步模块 705 还包括状态修改单元 7053 ,用于将数据状态为修改状态的子数据块的数 据状态修改为正常状态。 其中, 该修改同步模块 705中的轮询单元 7051 轮询子数据块的数据状态的过程, 以及修改同步单元 7052修改数据的 过程详见上述实施例中步骤 304的相关描述, 此处不再赘述。
参见图 11 , 装置还可以包括释放同步模块 706和释放模块 707。 其中, 释放同步模块 706用于根据业务逻辑将对应的子数据块中的 数据同步至网络存储设备。 释放模块 707用于在释放同步模块 706根据 业务逻辑将对应的子数据块中的数据同步至网络存储设备之后, 释放该 子数据块对应的共享内存。
进一步地, 参见图 11 , 释放同步模块 706包括查询单元 7061和释 放同步单元 7062。 其中, 查询单元 7061用于查询每个子数据块的数据 状态。 释放同步单元 7062用于将查询单元 7061查询到的数据状态为定 时释放状态的子数据块中的数据同步至网络存储设备。 进一步地, 释放 同步模块 706还包括状态修改单元 7063 ,用于将数据状态为定时释放状 态的子数据块的状态修改为空闲状态。 其中, 查询单元 7061 查询数据 状态的过程, 以及释放同步单元 7062 实现定时释放同步的过程详见上 述实施例中步骤 305的相关描述, 此处不再赘述。
参见图 12, 加载模块 702包括选择单元 7021和加载单元 7022。 其 中, 选择单元 7021 用于在所有子数据块中选择数据状态为空闲状态的 子数据块。 加载单元 7022用于根据业务逻辑需求, 将网络存储设备上 的数据存储至选择单元选择出的子数据块中。 进一步地, 加载模块 702 还包括状态修改单元 7023 ,用于将选择出的子数据块的数据状态由空闲 状态修改为加载状态, 并在数据加载完毕后, 将选择出的子数据块的数 据状态由加载状态修改为正常状态。 其中, 选择单元 7021 选择子数据 块的方式, 以及加载单元 7022加载数据的过程详见上述实施例中步骤 303的相关描述, 此处不再赘述。
参见图 13 , 该装置还包括建立模块 708和更新模块 709。 其中, 建 立模块 708用于建立二维数据緩存阵列与网络存储设备的映射关系表, 映射关系表存储在网络存储设备上, 并记录了每个逻辑数据块中的各个 子数据块的数据存储情况。 更新模块 709用于根据二维数据緩存阵列的 子数据块中的数据变化更新建立模块 707建立的映射关系表。 其中, 二 维数据緩存阵列中的每个逻辑数据块对应一个映射关系表, 每个逻辑数 据块中的子数据块对应映射关系表中的一条记录。
根据本实施例提供的装置, 通过根据预设的配置策略在本地共享内 存中配置可扩展的二维数据緩存阵列, 并根据业务逻辑需求, 将网络存 储设备上的数据存储至二维数据緩存阵列的对应的子数据块中, 实现本 地存储数据, 从而可以提高数据存储及交互的效率, 且由于存储数据的 二维数据緩存阵列为可扩展的, 因而提高了数据结构的可扩展性, 从而 能够满足业务逻辑的需求。 另外, 在子数据块中的数据修改后, 通过将 修改后的数据同步至网络存储设备, 进而实现本地共享内存与网络存储 设备的数据同步, 有效防止数据丟失。
需要说明的是: 上述实施例提供的存储数据的装置在存储数据时, 仅以上述各功能模块的划分进行举例说明, 实际应用中, 可以根据需要 而将上述功能分配由不同的功能模块完成, 即将装置的内部结构划分成 不同的功能模块, 以完成以上描述的全部或者部分功能。 另外, 上述实 施例提供的存储数据的装置与存储数据的方法实施例属于同一构思, 其 具体实现过程详见方法实施例, 这里不再赘述。
本发明实施例提供的方法和设备可以由硬件、 或计算机可读指令、 或者硬件和计算机可读指令的结合来实现。 本实施例中使用的计算机可 读指令由多个处理器存储在可读存储介质中, 例如硬盘、 CD-ROM、 DVD, 光盘、 软盘、 磁带、 RAM、 ROM或其它合适的存储设备。 或者, 至少部分计算机可读指令可以由具体硬件替换, 例如, 定制集成线路、 门阵列、 FPGA、 PLD和具体功能的计算机等等。
本发明实施例提供了计算机可读存储介质, 用于存储指令使得计算 机执行本文所述的方法。 具体地, 本实施例提供的系统或设备都具有存 储介质, 其中存储了计算机可读程序代码, 用于实现上述任意实施例的 功能, 并且这些系统或设备 (或 CPU或 MPU ) 能够读取并且执行存储 在存储介质中的程序代码。
在这种情况下, 从存储介质中读取的程序代码可以实现上述任一实 施例, 因此该程序代码和存储该程序代码的存储介质是技术方案的一部 用于提供程序代码的存储介质包括软盘、 硬盘、 磁光盘、 光盘(例 如 CD-ROM、 CD-R, CD-RW、 DVD-ROM、 DVD-RAM、 DVD-RW, DVD+RW ), 磁盘、 闪存卡、 ROM等等。 可选地, 程序代码也可以通过 通信网络从 务器电脑上下载。
应该注意的是, 对于由计算机执行的程序代码, 至少部分由程序代 码实现的操作可以由运行在计算机上的操作系统实现, 从而实现上述任 一实施例的技术方案, 其中该计算机基于程序代码执行指令。
另外, 存储介质中的程序代码被写入存储器, 其中, 该存储器位于 插入在计算机中的扩展板中, 或者位于连接到计算机的扩展单元中。 在 本实施例中,扩展板或扩展单元中的 CPU根据指令,基于程序代码执行 至少部分操作, 从而实现上述任一实施例的技术方案。
以上所述仅为本发明的较佳实施例, 并不用以限制本发明, 凡在本 发明的精神和原则之内, 所作的任何修改、 等同替换、 改进等, 均应包 含在本发明的保护范围之内。

Claims

权利要求书
1、 一种存储数据的方法, 其特征在于, 所述方法包括:
根据预设的配置策略在本地共享内存中配置可扩展的二维数据緩存 阵列, 所述二维数据緩存阵列包括多个逻辑数据块, 每个所述逻辑数据 块包括多个用于存储数据的子数据块;
根据业务逻辑需求, 将网络存储设备上的数据存储至所述数据对应 的子数据块中。
2、根据权利要求 1所述的方法, 其特征在于, 所述根据预设的配置 策略在本地共享内存中配置可扩展的二维数据緩存阵列之后, 还包括: 根据每个所述子数据块中存储的数据的情况, 为每个所述子数据块 设置数据状态, 所述数据状态为空闲状态、 加载状态、 正常状态、 修改 状态、 释放状态和定时释放状态中的一种。
3、根据权利要求 2所述的方法, 其特征在于, 所述根据业务逻辑需 求, 将网络存储设备上的数据存储至所述数据对应的子数据块中之后, 还包括: 根据业务逻辑, 修改所述子数据块中存储的数据, 并将修改后 的数据同步至所述网络存储设备。
4、根据权利要求 3所述的方法, 其特征在于, 所述将修改后的数据 同步至所述网络存储设备, 包括:
定时轮询每个所述子数据块的数据状态, 将所述数据状态为修改状 态的子数据块中的数据同步至所述网络存储设备。
5、根据权利要求 4所述的方法, 其特征在于, 所述将数据状态为修 改状态的子数据块中的数据同步至所述网络存储设备之后, 还包括: 将 所述数据状态为修改状态的子数据块的数据状态修改为正常状态。
6、根据权利要求 2所述的方法, 其特征在于, 所述根据业务逻辑需 求, 将网络存储设备上的数据存储至所述数据对应的子数据块中之后, 还包括:
根据业务逻辑将所述子数据块中的数据同步至所述网络存储设备, 并释放所述子数据块对应的共享内存。
7、根据权利要求 6所述的方法, 其特征在于, 所述根据业务逻辑将 所述子数据块中的数据同步至所述网络存储设备, 包括:
查询每个所述子数据块的数据状态, 并将所述数据状态为定时释放 状态的子数据块中的数据同步至所述网络存储设备。
8、根据权利要求 7所述的方法, 其特征在于, 所述将所述数据状态 为定时释放状态的子数据块中的数据同步至所述网络存储设备之后, 还 态。
9、根据权利要求 2所述的方法, 其特征在于, 所述根据业务逻辑需 求,将网络存储设备上的数据存储至所述数据对应的子数据块中, 包括: 在所有所述子数据块中选择数据状态为空闲状态的子数据块, 根据 业务逻辑需求, 将所述网络存储设备上的数据存储至选择的子数据块 中。
10、 根据权利要求 9所述的方法, 其特征在于, 所述将所述网络存 储设备上的数据存储至选择的子数据块中之后, 还包括:
将所述选择的子数据块的数据状态由空闲状态修改为加载状态, 并 在数据加载完毕后, 将所述选择的子数据块的数据状态由加载状态修改 为正常状态。
11、根据权利要求 1至 10中任一权利要求所述的方法,其特征在于, 所述根据预设的配置策略在本地共享内存中配置可扩展的二维数据緩 存阵列之后, 还包括: 建立所述二维数据緩存阵列与所述网络存储设备的映射关系表, 并 根据所述二维数据緩存阵列的子数据块中的数据变化更新所述映射关 系表, 所述映射关系表存储在所述网络存储设备上, 并记录了每个逻辑 数据块中的各个子数据块的数据存储情况; 其中, 所述二维数据緩存阵 列中的每个逻辑数据块对应一个所述映射关系表, 每个逻辑数据块中的 子数据块对应所述映射关系表中的一条记录。
12、 一种存储数据的装置, 其特征在于, 所述装置包括:
配置模块, 用于根据预设的配置策略在本地共享内存中配置可扩展 的二维数据緩存阵列, 所述二维数据緩存阵列包括多个逻辑数据块, 每 个所述逻辑数据块包括多个用于存储数据的子数据块;
加载模块, 用于根据业务逻辑需求, 将网络存储设备上的数据存储 至所述数据对应的子数据块中。
13、 根据权利要求 12所述的装置, 其特征在于, 所述装置还包括: 设置模块, 用于根据每个所述子数据块中存储的数据的情况, 为每 个所述子数据块设置数据状态, 所述数据状态为空闲状态、 加载状态、 正常状态、 修改状态、 释放状态和定时释放状态中的一种。
14、 根据权利要求 13所述的装置, 其特征在于, 所述装置还包括: 修改模块, 用于根据业务逻辑, 修改所述子数据块中存储的数据; 修改同步模块, 用于将所述修改模块修改后的数据同步至所述网络 存储设备。
15、根据权利要求 14所述的装置, 其特征在于, 所述修改同步模块 包括:
轮询单元, 用于定时轮询每个所述子数据块的数据状态;
修改同步单元, 用于将所述轮询单元轮询到的数据状态为修改状态 的子数据块中的数据同步至所述网络存储设备。
16、根据权利要求 15所述的装置,其特征在于,所述修改同步模块, 还包括: 状态修改单元, 用于将所述数据状态为修改状态的子数据块的 数据状态修改为正常状态。
17、 根据权利要求 13所述的装置, 其特征在于, 所述装置还包括: 释放同步模块, 用于根据业务逻辑将所述子数据块中的数据同步至 所述网络存储设备;
释放模块, 用于在所述释放同步模块根据业务逻辑将所述子数据块 中的数据同步至所述网络存储设备之后, 释放所述子数据块对应的共享 内存。
18、根据权利要求 17所述的装置,其特征在于,所述释放同步模块, 包括:
查询单元, 用于查询每个所述子数据块的数据状态;
释放同步单元, 用于将所述查询单元查询到的所述数据状态为定时 释放状态的子数据块中的数据同步至所述网络存储设备。
19、根据权利要求 18所述的装置,其特征在于,所述释放同步模块, 还包括: 状态修改为空闲状态。
20、 根据权利要求 13所述的装置, 其特征在于, 所述加载模块, 包 括:
选择单元, 用于在所有所述子数据块中选择数据状态为空闲状态的 子数据块;
加载单元, 用于根据业务逻辑需求, 将所述网络存储设备上的数据 存储至所述选择单元选择出的子数据块中。
21、 根据权利要求 20所述的装置, 其特征在于, 所述加载模块, 还 包括:
状态修改单元, 用于将所述选择出的子数据块的数据状态由空闲状 态修改为加载状态, 并在数据加载完毕后, 将所述选择出的子数据块的 数据状态由加载状态修改为正常状态。
22、 根据权利要求 12至 20中任一权利要求所述的装置, 其特征在 于, 所述装置还包括:
建立模块, 用于建立所述二维数据緩存阵列与所述网络存储设备的 映射关系表, 所述映射关系表存储在所述网络存储设备上, 并记录了每 个逻辑数据块中的各个子数据块的数据存储情况;
更新模块, 用于根据所述二维数据緩存阵列的子数据块中的数据变 化更新所述建立模块建立的映射关系表;
其中, 所述二维数据緩存阵列中的每个逻辑数据块对应一个所述映 射关系表, 每个逻辑数据块中的子数据块对应所述映射关系表中的一条 记录。
PCT/CN2013/072042 2012-03-09 2013-03-01 存储数据的方法及装置 WO2013131443A1 (zh)

Priority Applications (7)

Application Number Priority Date Filing Date Title
MX2014010780A MX352050B (es) 2012-03-09 2013-03-01 Método y dispositivo de almacenamiento de datos.
JP2014560227A JP5851055B2 (ja) 2012-03-09 2013-03-01 データ格納方法および装置
EP13757716.9A EP2824893B1 (en) 2012-03-09 2013-03-01 Data storage method and device
BR112014021885-4A BR112014021885B1 (pt) 2012-03-09 2013-03-01 Método e dispositivo de armazenamento de dados
KR1020147028190A KR101663215B1 (ko) 2012-03-09 2013-03-01 데이터 저장 방법 및 장치
PH12014501932A PH12014501932A1 (en) 2012-03-09 2014-08-27 Data storage method and device
US14/478,151 US20150006486A1 (en) 2012-03-09 2014-09-05 Method and apparatus for storing data

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210061555.8A CN103309818B (zh) 2012-03-09 2012-03-09 存储数据的方法及装置
CN201210061555.8 2012-03-09

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/478,151 Continuation US20150006486A1 (en) 2012-03-09 2014-09-05 Method and apparatus for storing data

Publications (1)

Publication Number Publication Date
WO2013131443A1 true WO2013131443A1 (zh) 2013-09-12

Family

ID=49115942

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/072042 WO2013131443A1 (zh) 2012-03-09 2013-03-01 存储数据的方法及装置

Country Status (9)

Country Link
US (1) US20150006486A1 (zh)
EP (1) EP2824893B1 (zh)
JP (1) JP5851055B2 (zh)
KR (1) KR101663215B1 (zh)
CN (1) CN103309818B (zh)
BR (1) BR112014021885B1 (zh)
MX (1) MX352050B (zh)
PH (1) PH12014501932A1 (zh)
WO (1) WO2013131443A1 (zh)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
IL235729A (en) * 2014-11-17 2017-06-29 Kaluzhny Uri A device and method for securely storing information
CN107040396A (zh) * 2016-02-03 2017-08-11 博雅网络游戏开发(深圳)有限公司 配置信息获取方法和装置
CN107346307B (zh) * 2016-05-04 2021-02-26 北京京东尚科信息技术有限公司 分布式缓存系统及方法
CN107562775B (zh) * 2017-07-14 2020-04-24 创新先进技术有限公司 一种基于区块链的数据处理方法及设备
CN107608627B (zh) * 2017-08-21 2020-10-02 云宏信息科技股份有限公司 一种远端数据分级存储方法、电子设备及存储介质
CN108073687B (zh) * 2017-11-17 2020-09-08 阿里巴巴集团控股有限公司 随机游走、基于集群的随机游走方法、装置以及设备
CN108566552B (zh) * 2018-04-20 2021-05-25 四川长虹网络科技有限责任公司 适用于数字机顶盒的多媒体播放方法及系统
CN109284236B (zh) * 2018-08-28 2020-04-17 北京三快在线科技有限公司 数据预热方法、装置、电子设备及存储介质
CN112448983B (zh) * 2019-09-02 2023-09-19 广州彩熠灯光股份有限公司 一种将多个物理设备集群为一逻辑设备的方法
CN113971195A (zh) * 2020-07-23 2022-01-25 北京字节跳动网络技术有限公司 同步数据方法、装置、电子设备和介质
CN115617770B (zh) * 2022-11-17 2023-03-28 达芬骑动力科技(北京)有限公司 一种用于车辆状态信号数据存储的数据磁盘存储管理方法
CN116107517B (zh) * 2023-04-11 2023-06-09 远江盛邦(北京)网络安全科技股份有限公司 数据同步方法、装置、电子设备和存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1545033A (zh) * 2003-11-14 2004-11-10 清华大学 Fc-san存储子系统的lun cache方法
CN101398821A (zh) * 2007-09-26 2009-04-01 新奥特硅谷视频技术有限责任公司 基于本地缓存和虚拟文件系统技术的网络存储方法及系统
CN102035881A (zh) * 2010-11-19 2011-04-27 清华大学 一种云端存储系统的数据缓存方法

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7269608B2 (en) * 2001-05-30 2007-09-11 Sun Microsystems, Inc. Apparatus and methods for caching objects using main memory and persistent memory
JP2005004282A (ja) * 2003-06-09 2005-01-06 Nec Corp ディスクアレイ装置、ディスクアレイ装置の管理方法及び管理プログラム
US7117310B2 (en) * 2004-02-18 2006-10-03 Lsi Logic Corporation Systems and methods for cache synchronization between redundant storage controllers
US7272687B2 (en) * 2005-02-01 2007-09-18 Lsi Corporation Cache redundancy for LSI raid controllers
JP4819369B2 (ja) * 2005-02-15 2011-11-24 株式会社日立製作所 ストレージシステム
US8035650B2 (en) * 2006-07-25 2011-10-11 Qualcomm Incorporated Tiled cache for multiple software programs
US20080091895A1 (en) * 2006-10-11 2008-04-17 Inventec Corporation Cache data backup method and system for computer clustering systems
CN101329657A (zh) * 2007-06-19 2008-12-24 瑞达信息安全产业股份有限公司 一种用于多应用间的安全共享动态内存系统和方法
JP4430092B2 (ja) * 2007-08-28 2010-03-10 富士通株式会社 Raid装置、raid装置の制御部およびraid装置のライトバック制御方法
CN101431525B (zh) * 2007-11-06 2012-08-29 北京傲游天下科技有限公司 网络内容加载的加速方法、系统及其服务器和终端
CN101330510A (zh) * 2008-06-19 2008-12-24 腾讯数码(深圳)有限公司 下发目录树数据的方法、系统和服务器,以及一种客户端
US8868838B1 (en) * 2008-11-21 2014-10-21 Nvidia Corporation Multi-class data cache policies
US8585505B2 (en) * 2008-12-15 2013-11-19 Tetris Online, Inc. Inter-game interactive hybrid asynchronous computer game infrastructure
US20140086309A1 (en) * 2011-06-16 2014-03-27 Freescale Semiconductor, Inc. Method and device for encoding and decoding an image

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1545033A (zh) * 2003-11-14 2004-11-10 清华大学 Fc-san存储子系统的lun cache方法
CN101398821A (zh) * 2007-09-26 2009-04-01 新奥特硅谷视频技术有限责任公司 基于本地缓存和虚拟文件系统技术的网络存储方法及系统
CN102035881A (zh) * 2010-11-19 2011-04-27 清华大学 一种云端存储系统的数据缓存方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2824893A4 *

Also Published As

Publication number Publication date
CN103309818B (zh) 2015-07-29
MX2014010780A (es) 2014-10-14
EP2824893A1 (en) 2015-01-14
CN103309818A (zh) 2013-09-18
JP5851055B2 (ja) 2016-02-03
KR101663215B1 (ko) 2016-10-14
KR20140133603A (ko) 2014-11-19
PH12014501932B1 (en) 2014-11-24
US20150006486A1 (en) 2015-01-01
MX352050B (es) 2017-11-06
BR112014021885A2 (zh) 2017-06-20
BR112014021885B1 (pt) 2022-05-17
JP2015509635A (ja) 2015-03-30
EP2824893A4 (en) 2015-05-27
EP2824893B1 (en) 2018-06-13
PH12014501932A1 (en) 2014-11-24

Similar Documents

Publication Publication Date Title
WO2013131443A1 (zh) 存储数据的方法及装置
US11042311B2 (en) Cluster system with calculation and storage converged
Liu et al. Cloud mapreduce: A mapreduce implementation on top of a cloud operating system
US20210117441A1 (en) Data replication system
EP2893688B1 (en) System and method for supporting message pre-processing in a distributed data grid cluster
US8117156B2 (en) Replication for common availability substrate
US20150169415A1 (en) Techniques to manage non-disruptive san availability in a partitioned cluster
US20100106915A1 (en) Poll based cache event notifications in a distributed cache
JP2017528809A (ja) 記憶不具合後の安全なデータアクセス
JP6195834B2 (ja) トランザクショナルミドルウェアマシン環境においてトランザクションレコードを永続化するためのシステムおよび方法
EP3039844B1 (en) System and method for supporting partition level journaling for synchronizing data in a distributed data grid
TWI746511B (zh) 資料表連接方法及裝置
JP2016508349A (ja) クラスタ境界にわたるサービス移行
US20210109778A1 (en) Migrating the runtime state of a container between two nodes
US10212218B2 (en) Elastically scalable document-oriented storage services
WO2018010501A1 (zh) 全局事务标识gtid的同步方法、装置及系统、存储介质
RU2643642C2 (ru) Использование кэш-памяти и памяти другого типа в распределённой запоминающей системе
Zhang et al. A novel solution of distributed file storage for cloud service
WO2023155591A1 (zh) 进度信息管控方法、微服务装置、电子设备及存储介质
WO2022218346A1 (zh) 一种故障处理方法及装置
WO2013101093A1 (en) Initialization of multi-core processing system
US10642788B1 (en) Sand timer algorithm for tracking in-flight data storage requests for data replication
WO2023231572A1 (zh) 一种容器的创建方法、装置及存储介质
WO2021168618A1 (zh) redis集群扩容方法、装置、电子设备以及存储介质
CN114296875A (zh) 基于容错系统的数据同步方法、系统及计算机可读介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13757716

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 12014501932

Country of ref document: PH

ENP Entry into the national phase

Ref document number: 2014560227

Country of ref document: JP

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: MX/A/2014/010780

Country of ref document: MX

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2013757716

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 20147028190

Country of ref document: KR

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: IDP00201406098

Country of ref document: ID

REG Reference to national code

Ref country code: BR

Ref legal event code: B01A

Ref document number: 112014021885

Country of ref document: BR

ENP Entry into the national phase

Ref document number: 112014021885

Country of ref document: BR

Kind code of ref document: A2

Effective date: 20140904