Data caching method, device, equipment and medium

文档序号:1098498 发布日期:2020-09-25 浏览:13次 中文

阅读说明:本技术 一种数据缓存方法、装置、设备及介质 (Data caching method, device, equipment and medium ) 是由 刘延兴 于 2020-08-20 设计创作,主要内容包括:本公开实施例涉及一种数据缓存方法、装置、设备及介质,其中该方法包括:获取待缓存数据;按照至少两个属性维度,确定所述待缓存数据的缓存权值,其中一个所述属性维度为访问时间;如果所述待缓存数据在缓存空间中未命中且所述缓存空间不满足数据淘汰条件,则基于所述待缓存数据的缓存权值,将所述待缓存数据存储在所述缓存空间。采用上述技术方案,数据可以基于包括时间的多个维度进行缓存,相较于现有的单一维度,有效提高了缓存空间数据的命中率和访问效率。(The embodiment of the disclosure relates to a data caching method, a data caching device and a data caching medium, wherein the method comprises the following steps: acquiring data to be cached; determining a caching weight of the data to be cached according to at least two attribute dimensions, wherein one attribute dimension is access time; and if the data to be cached is not hit in the cache space and the cache space does not meet the data elimination condition, storing the data to be cached in the cache space based on the cache weight of the data to be cached. By adopting the technical scheme, the data can be cached based on a plurality of dimensionalities including time, and compared with the existing single dimensionality, the hit rate and the access efficiency of the cache space data are effectively improved.)

1. A method for caching data, comprising:

acquiring data to be cached;

determining a caching weight of the data to be cached according to at least two attribute dimensions, wherein one attribute dimension is access time;

and if the data to be cached is not hit in the cache space and the cache space does not meet the data elimination condition, storing the data to be cached in the cache space based on the cache weight of the data to be cached.

2. The data caching method according to claim 1, wherein the determining the caching weight of the data to be cached according to at least two attribute dimensions comprises:

determining a cache weight of the data to be cached according to at least two attribute dimensions, a weight value of each attribute dimension and a cache weight formula, wherein the cache weight formula is rho = α1β12β2+···+α2β2ρ represents the buffer weight of the data to be buffered, β12,···,βnRepresenting each of said attribute dimensions, α12,···,αnA weight value representing each of the attribute dimensions.

3. The data caching method according to claim 1, wherein the cache space includes at least two cached data, and before acquiring the data to be cached, the method further includes:

and performing descending sorting on each cached data based on the sequence of the cache weight values from large to small, and storing the cached data in the corresponding storage position in the cache space based on the sorting result.

4. The data caching method of claim 3, wherein the data eviction condition is that the amount of cached data in the cache space is equal to a quantity threshold.

5. The data caching method according to claim 3, wherein the storing the data to be cached in the cache space based on the cache weight of the data to be cached comprises:

sequentially traversing each cached data in the cache space, and determining the cached data with a cache weight equal to the cache weight of the data to be cached as first target data, or determining the cached data with a cache weight smaller than the cache weight of the data to be cached and a minimum difference between the cache weight and the cache weight of the data to be cached as the first target data;

and storing the data to be cached at a target position in the cache space, wherein the target position is located at a previous storage position of the first target data.

6. The data caching method according to claim 3, wherein after determining the caching weight of the data to be cached according to at least two attribute dimensions, the method further comprises:

if the data to be cached is not hit in the cache space and the cache space meets the data elimination condition, after the cached data at the storage position corresponding to the last sequencing in the cache space is deleted, executing the cache weight value based on the data to be cached, and storing the data to be cached in the cache space.

7. The data caching method according to claim 3, wherein after determining the caching weight of the data to be cached according to at least two attribute dimensions, the method further comprises:

if the data to be cached hits in the cache space, determining the hit cached data as second target data;

and moving the second target data to a storage position corresponding to the cache weight of the data to be cached in the cache space.

8. A data caching apparatus, comprising:

the data acquisition module is used for acquiring data to be cached;

a weight determination module, configured to determine a cache weight of the data to be cached according to at least two attribute dimensions, where one of the attribute dimensions is access time;

and the data storage module is used for storing the data to be cached in the cache space based on the cache weight of the data to be cached if the data to be cached is not hit in the cache space and the cache space does not meet the data elimination condition.

9. An electronic device, characterized in that the electronic device comprises:

a processor;

a memory for storing the processor-executable instructions;

the processor is configured to read the executable instructions from the memory and execute the instructions to implement the data caching method of any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that the storage medium stores a computer program for executing the data caching method of any one of the preceding claims 1 to 7.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于电子信息的分布式数据保密处理系统及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类