Method for caching data

A data cache and data technology, applied in the field of network communication, can solve the problems of random IO reading ability, random reading and writing ability limitation, etc., and achieve the effects of reducing occupation, realizing separation, and improving storage capacity

CN103514106AActive Publication Date: 2014-01-15ULTRAPOWER SOFTWARE
3 Cites 31 Cited by

Patent Information

Authority / Receiving Office
CN · China
Current Assignee / Owner
Publication Date
2014-01-15

Smart Images

  • Figure 1
    Figure 1
  • Figure 2
    Figure 2
  • Figure 3
    Figure 3
Patent Text Reader

Abstract

The invention discloses a method for caching data. The method includes the steps that serialization processing is conducted on data placed in a cache; the cache is divided into a cold zone and a hot zone, and both the cold zone and the hot zone are of a bi-directional linked list structure; when the data are inserted into the cache, the data are firstly placed in the cold zone; when the data in the cache are hit, if the hit data are in the cold zone, whether the data are hit by preset times or not is judged, if yes, the data are transferred to the tail of the hot zone, if not, the data are transferred to the head of a linked list of the cold zone; if the hit data are in the hot zone, the data are transferred into the head of a linked list of the hot zone. By the adoption of the technical scheme, caching efficiency of the hot data is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

technical field

[0001] The invention relates to the technical field of network communication, in particular to a data caching method. Background technique

[0002] With the increase in the number of users of instant messaging products and the increase in user activity, the number of friends in instant messaging products has grown exponentially, and the pressure on the system for data access is bound to increase, and a large number of concurrent random accesses to the database are usually It is the bottleneck of the system, because it is a very random access for users to obtain relevant data of all their friends, and the random IO read ability of the database to the disk is limited by the random read and write ability of the disk itself.

[0003] Therefore, only by finding a way to determine hot data and caching as much hot data as possible (hot data refers to data that has been accessed more times, it can also be called active data, relatively, inactive data is called cold d...

Examples

Embodiment Construction

[0038] The core idea of ​​the present invention is: serialize the data put into the cache, reduce the occupied memory, cache as much data as possible, and adopt a new cache management method to realize the separation of hot and cold data, avoiding the Random access makes hot data obsolete.

[0039] In addition, after the data is cached, because the memory cache is lost after the service starts abnormally, a large number of business accesses will "penetrate" the cache to directly access the database.

[0040] In this regard, the present invention further periodically persists the cached hot data to the disk to form a dmp file, and then records the update of the cache into a log (log) file. If the service restarts, use the dmp file to restore the hot zone data in the cache, read the log file (recording the modification of the cache after persistence), and delete the corresponding modification record in the log file from the restored cache, that is The correctness of the cache c...